Prism Region Manager and adding a new region

Topics: Prism v2 - WPF 3.5
Mar 18, 2009 at 1:13 PM
Edited Mar 18, 2009 at 1:43 PM

I need to be able to create an define regions on the fly:

This is the code that returns me a new view from my user control loaded from a dll. (so I can use the same control multiple times)

KeyValuePair<string, string> selPortletView = (KeyValuePair<string, string


IPortletView portletView = m_ShellService.GetPortletViewInstance(selPortletView.Key);

I then create a new control on my main form, say a new Frame , and want to load this user control into the newly created frame..

I need to somehow add a new region to the region manager, associate the region with my Frame,  then assign the portletView to that region, I know how to add the usercontrol (below) but how to I add a new Region to my RegionManager?

m_MainRegionManager.Regions["new Region Name"].Add(portletView);



I worked this out now, no need to reply thanks.......

Mar 24, 2009 at 5:12 PM
Can you share your solution please?  I'm trying to do the same thing.
Mar 25, 2009 at 5:29 PM

Hi joshb,


If you have a reference to the FrameworkElement that you want to be associated with the new region (the Frame in previous case), you can use the RegionManager's SetRegionName static method to dynamically define a new region:


RegionManager.SetRegionName(myFrame, "newRegionName");


Have in mind that the RegionManager is a singleton instance, so if your Frame’s lifetime will be short, make sure to remove the region from it to prevent memory leaks.               


Hope it helps!


Matias Bonaventura