Prism RequestNavigate to new view

守給你的承諾、 提交于 2019-12-13 13:35:55

问题


I am using WPF Prism 6 with autofac and having issues navigating between views. What I have is a view that I only want to keep alive till I leave it, and the next time I navigate to it, I want to create a new version of this view.

On load, I regist an IModule that has the following code

_regionManager.RegisterViewWithRegion(RegionNames.MainRegion, 
                                      typeof(DxfDisplay.Views.DxfDisplay));

This registers my view and the system works on initial load, I implement the INavigationAware and IRegionMemberLifetime interfaces on the view model and have public bool KeepAlive => false; implementing the IRegionMemberLifetime so that my view is disposed when I am done.

When I navigate away from this view everything is fine, but when I attempt to navigate to navigate to the view using

_regionManager.RequestNavigate(RegionNames.MainRegion, 
                               new Uri("DxfDisplay", UriKind.Relative), parameters);

The view is not opened and a view model constructor is not called. To make the navigation work correctly, I need to register with view with the region again. Or if I change the KeepAlive to true I can navigate back to the original view, but I cannot generate a new view if INavigationAware.IsNavigationTarget returns false.

My question is how do I register the view with the region manager in such a way that when I call _regionManager.RequestNavigate, it will create a new instance of the view and display it. I feel like I am missing something simple and just overlooking it.


回答1:


_builder.RegisterTypeForNavigation<DxfDisplay.Views.DxfDisplay>();



来源:https://stackoverflow.com/questions/39024136/prism-requestnavigate-to-new-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!