[英]Win universal app using Prism NavigationService with Frame control
我们如何将Prism NavigationService与Frame控件结合在一起? 我有一个包含框架的主页。 首先,我必须导航到主页,之后要更改NavigationSerices,以使其使用框架而不是整个页面。
因此,我需要Windows-Store-App-Prism框架中Prism 5.0中的区域。
已经解决了类似的问题:将导航服务注册到框架元素而不是页面-WinRt Prism 2.0,但我不喜欢此解决方案。
解决方案:在从MvvmAppBase继承的App.xaml.cs中添加:
public static App Instance { get { return _instance; } }
private Type Resolve(string name)
{
return Type.GetType(string.Format("{0}.Views.{1}Page", this.GetType().Namespace, name));
}
public void CreateNewNavigationFrame(Frame frame)
{
this.NavigationService = new FrameNavigationService(new FrameFacadeAdapter(frame), Resolve, this.SessionStateService);
}
在主页(框架所在的页面)的构造函数中:
public AppShellPage()
{
this.InitializeComponent();
App.Instance.CreateNewNavigationFrame(this.frame);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.