Xaml 在通用Windows应用程序的多个页面上将AppBar用作资源
我想在多个页面上使用AppBar作为资源。 我找到了一个MSDN文档(),但它是针对Windows Phone的 有人知道这是否适用于通用应用程序吗 这就是我的App.xaml现在的样子:Xaml 在通用Windows应用程序的多个页面上将AppBar用作资源,xaml,win-universal-app,Xaml,Win Universal App,我想在多个页面上使用AppBar作为资源。 我找到了一个MSDN文档(),但它是针对Windows Phone的 有人知道这是否适用于通用应用程序吗 这就是我的App.xaml现在的样子: <Application.Resources> <AppBar x:Key="GlobalBar" ClosedDisplayMode="Minimal"> <!--Controls....--> </AppBar> </A
<Application.Resources>
<AppBar x:Key="GlobalBar" ClosedDisplayMode="Minimal">
<!--Controls....-->
</AppBar>
</Application.Resources>
但是我如何在MainPage.xaml上实现这一点呢?遗憾的是,您不能完全按照自己的意愿去做……但是您可以使用不同的方法来实现它。使用单个母版页-添加框架和单个AppBar。框架将负责页面导航。我还建议您在UWP应用程序中使用commandBar而不是AppBar。 您可以在MainPage.xaml中将其用作-
<Page
x:Class="App2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.BottomAppBar>
<AppBar>
</AppBar>
</Page.BottomAppBar>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<!--Your Code-->
</Grid>
实现这一点的最快、最简单的方法是使用带有AppBar和主框架的页面
现在,所有页面中都有一个应用程序栏。在页面中,您可以使用
this.Frame.Navigate(…)
进行导航。在AppBar所在的rootPage中,您可以使用rootFrame.Navigate(…)
太糟糕了,这不可能像我希望的那样,感觉有点像回到WinForms。但是谢谢你的选择!因为你还添加了导航选项,所以我接受了你的答案。这似乎是这个问题的最佳答案。如果您想使用新的UWP SplitView控件并在每个视图上使用它,那么您必须做同样的事情。我用来解决这个问题的方法(使用母版页)与我在answer plus导航管理器中描述的方法相同。美好的