我正在尝试显示一个简单的弹出(带信息内容)当按下bilthAppBar中的AppBartoggleButton时,但我的解决方案不起作用。:(

这是我的代码:

<Page.BottomAppBar>
        <CommandBar>
            <AppBarToggleButton x:Uid="MapPageAppBarLegend" Label="" Icon="List">
                <FlyoutBase.AttachedFlyout>
                    <Flyout>
                        <TextBlock Text="Informations here..."/>
                    </Flyout>
                </FlyoutBase.AttachedFlyout>
            </AppBarToggleButton>
        </CommandBar>
</Page.BottomAppBar>
.

没什么看。有人可以帮助我展示这个剥夺吗? 非常感谢您的英语语言。:)

pame

有帮助吗?

解决方案

一切都很清楚地描述在msdn (还有一个非常好的例子):

没有任何内容,因为 flyouts 仅为按钮自动打开(和 appbartogglebutton 不会导出来自Button类):

当用户单击按钮时,将自动随附在按钮上打开。您不需要处理任何事件以打开弹出口。 (这包括从按钮派生的控件,如appbarbutton

当然,您可以将生成的Flyout添加到任何生成扫描仪中,但您必须手动打开它:

您可以使用FlyoutBase.AttachedFlyout附加属性将弹出窗口控件连接到任何FrameworkElement对象。如果您这样做,您必须响应FrameworkElement上的交互,例如拍摄的事件,并在代码中打开弹性。

在XAML中 - 在资源中定义您的FrameworkElement并将其附加到按钮:

<Page.Resources>
    <Flyout x:Key="myFlyout" Placement="Top">
        <TextBlock Text="Informations here..."/>
    </Flyout>
</Page.Resources>
<Page.BottomAppBar>
    <CommandBar>
        <AppBarToggleButton x:Uid="MapPageAppBarLegend" Label="First" Icon="List"
                            FlyoutBase.AttachedFlyout="{StaticResource myFlyout}"
                            Click="AppBarToggleButton_Click"/>                
    </CommandBar>
</Page.BottomAppBar>
.

和代码后面的事件:

private void AppBarToggleButton_Click(object sender, RoutedEventArgs e)
{
    FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender);  
}
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top