【问题标题】:Metro UI App Bar show on click buttonMetro UI 应用栏在点击按钮上显示
【发布时间】:2012-03-17 11:01:26
【问题描述】:

我想显示基于按钮的底部应用程序栏。有什么想法吗?我正在开发 Window 8 Consumer Preview Metro 应用程序。

这是应用栏的代码

<AppBar x:Name="GlobalAppBar" Padding="10,0,10,0">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50*"/>
                    <ColumnDefinition Width="50*"/>
                </Grid.ColumnDefinitions>
                <StackPanel Margin="20,0,0,0" VerticalAlignment="Center">
                    <TextBlock x:Name="topBarText" Text="You can add stuff here as well .." FontSize="26" />
                </StackPanel>
            </Grid>
        </AppBar>

通常,AppBar 是基于鼠标右键单击显示的,而我希望基于按钮单击事件显示它。任何想法? =D请

【问题讨论】:

    标签: c# c#-4.0 window microsoft-metro


    【解决方案1】:

    您可以通过设置 IsSticky 和 ​​IsOpen 属性来控制应用栏显示和关闭的方式和时间。您可以通过处理 Opened 和 Closed 事件来响应应用栏的打开或关闭。

    取自"Quickstart: adding an app bar with commands" section Remarks

    【讨论】:

    • 谢谢你的评论老兄=D
    【解决方案2】:

    无法想象您为什么要这样做,但您可以尝试...

    给你的页面添加一个按钮->

        <Button Content="App Bar open/close" Click="Button_Click_1" Margin="24,480,0,110" Grid.Row="1" />
    

    然后在 Click="Button_Click_1" 事件中->

    private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (!this.BottomAppBar.IsOpen)
            {
                this.BottomAppBar.IsOpen = true;
            }
            else
            {
                this.BottomAppBar.IsOpen = false;
            }
        }
    

    尽情尝试吧……

    【讨论】:

      【解决方案3】:

      MyAppBar.IsOpen = true;

      在你的活动中试试这个

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-20
        • 2016-01-02
        • 2021-12-31
        • 2015-08-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多