点击按钮上显示Metro UI App栏

时间:2012-03-17 11:01:27

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

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

以下是App Bar的代码

<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请

3 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:1)

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

在页面中添加一个按钮 - &gt;

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

然后在Click =“Button_Click_1”事件 - &gt;

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

尝试尝试......

答案 2 :(得分:0)

MyAppBar.IsOpen = true;

在你的活动中试试这个