Cameron Hurst Cameron Hurst - 7 months ago 75
C# Question

prism RequestNavigate to new view

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

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
interfaces on the view model and have
public bool KeepAlive => false;
implementing the
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
I can navigate back to the original view, but I cannot generate a new view if
returns false.

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