Cedric Royer-Bertrand Cedric Royer-Bertrand - 3 months ago 31
C# Question

WPF, How Prism link Views and URI

I'm learning Prism and I don't understand how the navigation is done with the URI. In this documentation example, the code on github use:

private void Button_Click(object sender, RoutedEventArgs e)

this.regionManager.RequestNavigate(RegionNames.MainContentRegion, calendarViewUri);

The URI is declared like this:

private static Uri calendarViewUri = new Uri("CalendarView", UriKind.Relative);

There is a CalendarView.xaml declared, in the code, but how the link is done?
Is Prism just look at the URI and try to find a matching view name then load it into the region?

If my assumption is correct, there is no need to register the link between the URI and the View. But what if a view is renamed, that means the navigation will be broken, am I right?


For the "missing link", look at ViewSwitchingNavigation.Calendar/CalendarModule.cs, this is where the calendar module is initialized, i.e. where it makes all its stuff known to the rest of the application:


This basically says "when asked to navigate to "CalendarView", create an instance of CalenderView".