tags:

views:

671

answers:

2

Hi there,

We have multiple project solution based on MS Prism in WPF. For ease of understanding lets take we have project shell, and project usercontrol. The usercontrol project has numerous views for various functions. We have a pop up window in shell project which is called from main shell window, what i want is to load different view into pop up window region manager based on requirement. Any help/suggestion through flow explanation or some code samples will be highly appreciable.

Regards

A: 

Using a Dependency Injection Container (such as Unity which can also be obtained from the CompositeWPF Microsoft page), you'll be able to pass around an instance of IRegionManager to your various modules/pop-up windows...

For example, in the view you wish to inject another view into, you could have a named ItemsControl:

<ItemsControl cal:RegionManager.RegionName="Modules" />

To fill it with your custom view, all you'd have to do from code is:

_regionManager.Regions["Modules"].Add(view);

(Where _regionManager could be an instance variable populated via Dependency Injection to the constructor of the class it's in). Don't worry about registering the IRegionManager interface with the container, that's done by the UnityBootstrapper during configuration.

Robert Reid
+1  A: 

Hi Deepak,

You can use the PopupRegionBehavior that comes with the Prism-v2 RI to achieve what you are trying to do in a decoupled way. You can read more about it here.

Please let me know if this helps.

Thanks, Damian

Damian Schenkelman