Prism : loading « on demand » a view in a region ?

Topics: Prism v2 - Silverlight 3, Prism v2 - Silverlight 4, Prism v2 - WPF 3.5, Prism v4 - WPF 4
Feb 10, 2011 at 8:49 AM

Let’s say that a Rightview is not added in a RightRegion by the Module.initialize().

Only an event on the Leftview in a LeftRegion can load it.

Wich class can dot this ?

-          The LeftViewModel must not know about other views (decoupled)…

-          Sending an event from the LeftViewModel  can’t work because the RightView is not loaded yet…

So, how can we do ?

- using a controller ? or something else ? do you have an exemple ?


Feb 10, 2011 at 7:47 PM


Based on my understanding of your scenario, your need to load a view in the RightRegion when the user takes an action which is located on LeftRegion.

One possible way to achieve this requirement will be use View Injection approach with EventAggregator . You can read about these topics in the following links:

With EventAggregator you allow publishers and subscribers to communicate through events without having any reference between each other. 

For example, on the controller you subscribe to your event and you could do something like this:

IRegion region = regionManager.Regions["RightRegion"]; 
var rightView = container.Resolve<IRightView>();
region.Add(rightView, "RightView"); region.Activate(rightView); 


On the other hand, you might find the UI Composition QuickStart handy, where this approach is covered. 

Please let me know if this information helps you.


Miguel Bronzovic