PRISM - reusing views with child regions - can this be done?

I'm a little new to PRISM, but I read the help documentation and can't figure out how to achieve the following (this is a WPF application).

I have a Shell (Window) in which there are two areas called "region1" and "region2". in the Initialize method of my one and only module, I register one view with each scope:

 regionViewRegistry.RegisterViewWithRegion("Region1", typeof(View1)); regionViewRegistry.RegisterViewWithRegion("Region2", typeof(View1)); 

and when I run it, everything is fine when it creates 2 separate instances of View1 and places them in each area.

Now in View1 I have declared my own region for entering small child views

 <ItemsControl Name="MainRegion" cal:RegionManager.RegionName="MainRegion" /> 

Now when I run my very simple PRISM application, I get the following exception message:

"A region with this name has already been registered: MainRegion"

which suggests that I cannot have multiple instances of the same view if that view declares its own scope.

Is it correct?

seems like a huge limitation.

I want my application to be very modular, as well as have an idea of ​​other views (across regions), etc.

Or did I read the documentation incorrectly?

+4
source share
1 answer

You can create a separation of shell level areas with areas created by module views using RegionScope. Any region that you create without a scope is "global" and does not have two regions with the same name in the same region.

You can learn more about cloud areas in this MSDN article: http://msdn.microsoft.com/en-us/magazine/cc785479.aspx#id0090126

+6
source

Source: https://habr.com/ru/post/1337355/


All Articles