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=""/> </Style>
這樣就可以通過設定Button屬性 Style="{StaticResource RefreshAppBarButtonStyle}" 來更改Button樣式