Robert J.
Robert J.

Reputation: 2711

prism 6 nested regions navigation

I have a region within a region. Main region (which holds all the others) is named ContentRegion and the other one which I used to display partial info is named SettingsRegion.

Under my bootstrapper I have defined the following:

        Prism.Regions.IRegionManager contentRegion = Container.TryResolve<Prism.Regions.IRegionManager>();

        #region Register Multiple Regions
        //contentRegion.RegisterViewWithRegion("ContentRegion", typeof(MainWindow));
        contentRegion.RegisterViewWithRegion("SettingsRegion", typeof(SettingsView_MainPage));


        #endregion

I can navigate from my ContentRegion to SettingsRegion without a problem like following:

_regionManager.RequestNavigate("ContentRegion", Experiences.Navigation.SettingsView_MainPage.ToString());

_regionManager.RequestNavigate("SettingsRegion", Experiences.NavigationSettings.SettingsView_ShiftSettings.ToString());

Everything renders great, I can see both views (contents) at the same time. However when I try to navigate back to main page like following

_regionManager.RequestNavigate("ContentRegion", Experiences.Navigation.MainPage.ToString());

It gives me the following error: {"Region with the given name is already registered: SettingsRegion"}

I have read multiple articles regarding nested Regions, however I could not implement none. I should probably also mention that I am using Unity as well.

I am also attaching pictures so that my explanation is less confusing.

Main View / Main Window enter image description here

Second view where I want to show some detail under the nested region enter image description here

Upvotes: 0

Views: 1483

Answers (1)

Robert J.
Robert J.

Reputation: 2711

So in the end I had to do the following adjustments:

remove completely the following line from Bootstrapper (I don't understand why I don't need to register it).

contentRegion.RegisterViewWithRegion("SettingsRegion", typeof(SettingsView_MainPage));

Afterwards had to do slight change under my SecondPageViewModel; originally I was directly navigating to sub page under the constructor, but once I implemented INavigationAware and moved the navigation to OnNavigatedTo then it suddenly started working.

Upvotes: 1

Related Questions