Scoped Region in Prism V2

Topics: Prism v2 - Silverlight 2, Prism v2 - WPF 3.5
Mar 16, 2009 at 3:13 PM
Is there an easier way in Prism V2 to deal with the Scoped Region, because it quickly becomes a mess when we have several nested Scoped Regions!
My solution is to put a property RegionManager in each view and I set it with the right RegionManger when I create the view, as is I can retreive the RegionManager of the any view without knowing it belongs to a new Scoped Region.
But I wonder if there is a better way to retrieve the RegionManager of an already instantiated View (potentially in a scoped region)?
Thanks by advance,
Dgis
Mar 17, 2009 at 7:07 PM

Hi Dgis,

 

A possible approach, recommended in the Composite Application Guidance for WPF & Silverlight documentation, could be placing the code to manage the views in a controller class that coordinates the activity of multiple views. If you create a controller class for each scoped region, save a reference to the region manager. When you add new view to that region, you can get a reference to its related controller.

 

However, if you want to get the RegionManager from a particular view you could use a method similar to the FindRegionManager helper method of the RegionManagerRegistrationBehavior class.(Full namespace: Microsoft.Practices.Composite.Presentation.Regions.Behaviors). This private method gets a dependency object (which can be your view) as a parameter and returns its related RegionManager by walking up the element tree.

 

Please let me know if this helps.

 

Damian Schenkelman

http://blogs.southworks.net/dschenkelman

Mar 19, 2009 at 9:42 PM
I already have controllers (and controller of controller) which can save the RegionManager, but I don't like to put the RegionManagers in a dictionary besides the views !
Thank for your help, I think your idea about the helper will help me.
Dgis