使用此XAML:
<Page.BottomAppBar>
<AppBar x:Name="bottomAppBar" Padding="10,0,10,0">
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Button Style="{StaticResource BrowsePhotosAppBarButtonStyle}" Click="btnOpenImgFiles_Click"/>
<Button Style="{StaticResource OpenAppBarButtonStyle}" Click="btnOpenMap_Click"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource SaveAppBarButtonStyle}" Click="btnSaveMap_Click"/>
</StackPanel>
</Grid>
</AppBar>
</Page.BottomAppBar>
(我改编自网上找到的标记)我得到了一个&#34; Windows.UI.Xaml.Markup.XamlParseException &#34;
看this,我认为它应该是AppBarButton而不是Button,所以我把它们改成了......但是我仍然得到同样的错误信息。是因为没有&#34; BrowsePhotosAppBarButtonStyle&#34; (我无法找到有效值列表)或...... ???
答案 0 :(得分:1)
是。它可能是基于传统Windows 8代码的按钮样式。如果您的目标是Windows 8.1,那么您应该使用AppBarButtons而不是Buttons。我还将它们放在CommandBar中,而不是在AppBar中布局自己的Grid。
如果BrowsePhotosAppBarButtonStyle不是特定于您从中获取的样本,则可能在Windows 8模板附带的StandardStyles.xaml文件中提供。该文件包含大量注释掉的按钮样式,供您根据需要取消注释。
以下是在Windows 8.1应用中进行设置的方法。为简单起见,我没有连接Click处理程序,您可能想要更新Label和Automation名称:
<Page.BottomAppBar>
<AppBar x:Name="bottomAppBar" Padding="10,0,10,0">
<CommandBar>
<CommandBar.SecondaryCommands>
<AppBarButton Icon="BrowsePhotos" Label="Browse" AutomationProperties.Name="Browse Photos" />
</CommandBar.SecondaryCommands>
<CommandBar.PrimaryCommands>
<AppBarButton Icon="OpenFile" Label="Open" AutomationProperties.Name="Open File"/>
<AppBarButton Icon="Save" Label="Save" AutomationProperties.Name="Save File"/>
</CommandBar.PrimaryCommands>
</CommandBar>
</AppBar>
</Page.BottomAppBar>
有关详细信息,请参阅Adding app bars (XAML)。