View Switching Navigation using Prism,MVVM,Unity
c#, mvvm, navigation, prism, unity-container
Solution
To Navigate is alot easier to do than in your code. Here's how i did it for a project.
//Register your View on Startup
container.RegisterType<object, LabStatusView>("LabStatusView");
//Navigation works like this
var labStatusView = new Uri("LabStatusView", UriKind.Relative);
regionManager.RequestNavigate("HorizonNavigatorView", labStatusView);
Can you try it like this?
Also many people use static classes for their Region and View name to avoid "magic strings". Something like this.
public class RegionNames
{
public const string HorizonNavigatorView = "HorizonNavigatorView";
}
public class ViewNames
{
public const string LabStatusView = "LabStatusView";
}
Problem
``` container.RegisterType<object, LabStatusView>("LabStatusView"); Uri LabStatusViewUri = new Uri("pack://application:,,,/LabStatus;component/LabStatusView.xaml", UriKind.Absolute); regionManager.RequestNavigate("HorizonNavigatorView",LabStatusViewUri,NavigationCompleted); ``` I am using this to navigate to LabStatusView, which seems straightforward. ObjectStates after the requestNavigate is executed: - regionManager.Regions.ActiveRegion contains one object of type "Object" instead of LabStatusView. - The only quirk of using Unity known to me is that i have register my type using overload of RegiterType method. Any suggestion what i am doing wrong here ?