I'm a bit of a PRISM newbie, but I've read the help documentation and can't seem to find out how to achieve the following (this is a WPF application)
I have a Shell
(Window) that has 2 regions called 'region1' and 'region2'.
in the Initialize
method of my one and only module, I am registering the same view with each region:
regionViewRegistry.RegisterViewWithRegion("Region1", typeof(View1));
regionViewRegistry.RegisterViewWithRegion("Region2", typeof(View1));
and when I run it everything is OK at this point as it creates 2 individual instances of View1
, and places one in each region.
Now in View1
I have declared its own region for injecting small child views
<ItemsControl Name="MainRegion" cal:RegionManager.RegionName="MainRegion" />
Now when I run my very simple PRISM app I get the following exception message:
"Region with the given name is already registered: MainRegion"
which suggests that I cannot have multiple instances of the same view if that view declares its own regions.
Is this correct ?
seems like a huge limitation.
I want my application to be highly modular, and to have view compose themselves of oother views (via regions) etc.
Or have I mis-read the documentation?
You can create a separation of shell-level regions with regions created by module views by using RegionScope. Any region you create without a scope is "global" and having two regions with the same name in the same scope isn't supported.
You can read more about Region Scopes in this MSDN article: http://msdn.microsoft.com/en-us/magazine/cc785479.aspx#id0090126
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With