您可以使用区域框架。这是 MvvmCross 的示例。
<SplitView x:Name="RootSplitView"
DisplayMode="Inline"
OpenPaneLength="256"
IsTabStop="False">
<SplitView.Pane>
<StackPanel Margin="0,50,0,0">
<Button Content="Second" Command="{x:Bind Vm.SecondCommand}" />
<Button Content="Third" Command="{x:Bind Vm.ThirdCommand}" />
</StackPanel>
</SplitView.Pane>
<!-- OnNavigatingToPage we synchronize the selected item in the nav menu with the current page.
OnNavigatedToPage we move keyboard focus to the first item on the page after it's loaded and update the Back button. -->
<Frame x:Name="FrameContent">
<Frame.ContentTransitions>
<TransitionCollection>
<NavigationThemeTransition>
<NavigationThemeTransition.DefaultNavigationTransitionInfo>
<EntranceNavigationTransitionInfo/>
</NavigationThemeTransition.DefaultNavigationTransitionInfo>
</NavigationThemeTransition>
</TransitionCollection>
</Frame.ContentTransitions>
</Frame>
</SplitView>
在文件后面的代码中添加
public Frame AppFrame { get { return (Frame)this.WrappedFrame.UnderlyingControl; } }
在 setup.cs 文件中添加这个
protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
{
return new MvxWindowsMultiRegionViewPresenter(rootFrame);
}
对于较新的版本,请使用:
protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
{
return new MvxWindowsMultiRegionViewPresenter(rootFrame);
}
在子视图的代码隐藏文件顶部添加以下属性:
[MvxRegion("FrameContent")]
对于以后的版本:
[MvxRegionPresentation("FrameContent")]
使用它导航到子视图:
ShowViewModel<SecondViewModel>()
参考此链接:https://depblog.weblogs.us/2015/11/23/mvvmcross-uwp-splitview/
示例:https://github.com/MvvmCross/MvvmCross-Samples/tree/master/XPlatformMenus