regions and views

Topics: Prism v2 - WPF 3.5
Dec 17, 2009 at 1:46 PM


Im having problems with regions/view, i have a shell which sets up a number of regions (including a MenuButtonregion, MainRegion), then the menu button gets populated by modules that inject there MenuButtonViews, alls good with this, which makes me happy :-). Then when one of the buttons is clicked a DelegateCommand in the particular MenuButtonViewModel is used to notify the my ModuleController to diplay the view for the MainRegion. This again works nicely, up until the point that one of the Views injected into MainRegion has set itself up some subregions, at this point any attempts to click the mainmenu button will result in an exception becuase I cannot add a view into the MainRegion that now has subregions attached.

What I really want to do (I guess), is prior to injecting a view into the mainRegion I should do some checking on that region and do any necessary unloading of existing views/subregions in it.

What is the best way to achieve this?

Many Thanks, Mark




Dec 22, 2009 at 8:46 PM

Hi Mark,

I have tried to reproduce your issue with no success. I have created a sample application which addresses your scenario so you can compare the differences. You can download it from here.

Please let me know if this helps.

Damian Schenkelman