1
votes

We are using Prism 7.2.0.1441-ci in our WPF app. We have a problem that the INavigationAware methods are not being called when navigating to a view. We use the below code to navigate. The Login view is registered. The LoginViewModel has implemented INavigationAware

    _regionManager.RegisterViewWithRegion(RegionNames.TabRegion, typeof(Login));
    _regionManager.RequestNavigate(RegionNames.TabRegion, ViewNames.Login, parameters);

MainWindow.xaml

       <DockPanel>
            <!-- <Frame x:Name="_mainFrame" NavigationUIVisibility="Hidden" /> -->
          <ContentControl  prism:RegionManager.RegionName="{x:Static core:RegionNames.TabRegion}"  />
          </DockPanel>

This mechanism does work in another part of the app, this particular bit is in the startup code and is being called from the MainWindowViewModel constructor.

Any ideas?

Thanks

1
Why do you register the view with the region and (try to) navigate to it? - Haukinger

1 Answers

1
votes

This mechanism does work in another part of the app, this particular bit is in the startup code and is being called from the MainWindowViewModel constructor.

You cannot navigate from the shell view model's constructor, because the regions aren't there yet.

Instead, do the first navigation from OnInitialized (or let the user click a button).