Load Views On Demand

Topics: Prism v2 - WPF 3.5
Sep 22, 2009 at 8:32 AM


I guess I'm missing something obvious here, but I just can't understand how to load views into region on demand.

Say I have a button, and when it clicked I want to display ViewA in RegionA. What should I do in order to accomplish that?

All of the samples in the docs demonstrates how to register a view in a region to be displayed immediately, but this is not what I'm looking for.

So - how can that be done?



Sep 24, 2009 at 7:03 PM


If you want to show a view in a region when a button is clicked you can use code similar to this (assuming view is a ViewA instance):

if (!regionManager.Regions["RegionA"].Views.Contains(view)) 

Take into account that the activate method only works if the region is attached to a ContentControl or Selector.

You can find more information on this topic here.

Please let me know if this helps.

Damian Schenkelman