我想基于按钮显示底部应用栏。有什么想法怎么做?我正在开发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请
答案 0 :(得分:1)
您可以通过设置IsSticky和IsOpen属性来控制显示和解除应用栏的方式和时间。您可以通过处理已打开和已关闭的事件来响应正在打开或关闭的应用栏。
取自"Quickstart: adding an app bar with commands" section Remarks
答案 1 :(得分:1)
无法想象为什么你想这样做,但你可以试试......
<Button Content="App Bar open/close" Click="Button_Click_1" Margin="24,480,0,110" Grid.Row="1" />
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;
在你的活动中试试这个