Windows 8 应用栏

Windows 8中右键鼠标或者操作触摸屏,屏幕底层会弹出一个菜单,这个就是应用栏。

应用栏类似于Windows Phone中的菜单栏:

 1 <Page.BottomAppBar>
 2     <AppBar x:Name="BottomAppBar">
 3         <Grid>
 4             <Grid.ColumnDefinitions>
 5                 <ColumnDefinition Width="50*"/>
 6                 <ColumnDefinition Width="50*"/>
 7             </Grid.ColumnDefinitions>
 8             <StackPanel x:Name="LeftPanel" Orientation="Horizontal" Grid.Column="0" HorizontalAlignment="Left">
 9                 <Button x:Name="Edit" Style="{StaticResource EditAppBarButtonStyle}" Click="Edit_Button_Click"/>
10                 <Button x:Name="Save" Style="{StaticResource SaveAppBarButtonStyle}"/>
11                 <Button x:Name="Delete" Style="{StaticResource DeleteAppBarButtonStyle}"/>
12             </StackPanel>
13             <StackPanel x:Name="RightPanel" Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right">
14                 <Button x:Name="Refresh" Style="{StaticResource RefreshAppBarButtonStyle}"/>
15             </StackPanel>
16         </Grid>
17     </AppBar>
18 </Page.BottomAppBar>

AppBar标签中就是一个控件区域,可以设置任意的布局,上例设置的是我们在Win8应用中常见的布局,左侧几个按钮,右侧几个按钮

按钮直接用Button控件表示,事件或Name自己添加,样式一般是用系统自带的样式,样式文件都在工程文件的路径Common/StandardStyles.xaml中

默认这些样式的配置都是被注释的,如果需要哪些按钮样式,需要手动取消注释,如下

<Style x:Key="RefreshAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
        <Setter Property="AutomationProperties.AutomationId" Value="RefreshAppBarButton"/>
        <Setter Property="AutomationProperties.Name" Value="Refresh"/>
        <Setter Property="Content" Value="&#xE117;"/>
    </Style>

这样就可以通过设置Button属性 Style="{StaticResource RefreshAppBarButtonStyle}" 来更改Button样式

原文地址:https://www.cnblogs.com/fengbeihong/p/3023537.html