这是你如何做到的。
public sealed partial class App : PrismUnityApplication
{
public App()
{
InitializeComponent();
}
protected override UIElement CreateShell(Frame rootFrame)
{
var masterPage = Container.Resolve<MasterPage>();
masterPage.MyFrame = rootFrame;
return masterPage;
}
protected override Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args)
{
NavigationService.Navigate(Keys.MainPage, null);
return Task.FromResult(true);
}
}
接着。
public sealed partial class MasterPage : Page
{
public MainPage()
{
InitializeComponent();
NavigationCacheMode = NavigationCacheMode.Enabled;
}
public Frame MyFrame
{
get { return (Frame)GetValue(MyFrameProperty); }
set { SetValue(MyFrameProperty, value); }
}
public static readonly DependencyProperty MyFrameProperty =
DependencyProperty.Register(nameof(MyFrame), typeof(Frame),
typeof(MasterPage), new PropertyMetadata(null));
}
接着。
<Page>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<CommandBar Grid.Row="0" Content="Header" />
<ContentPresenter Grid.Row="1" Content="{x:Bind MyFrame, Mode=OneWay}" />
</Grid>
</Page>
再次,我建议你看看@ http://aka.ms/template10
祝你好运。