Topics: Prism v4 - WPF 4
Nov 15, 2010 at 4:06 PM

So most descriptions of the MVVM pattern state that ViewModels should not have access to the View it services at least not in a direct way. It seems to me that the RegionManager implementation forces us to have at the very least an indirect reference to the view. Take for example a CloseCommand that exists on a ViewModel. In order to remove said view from the region manager that command would need to have access to its view either directly or indirectly in order to call the RegionManager's remove methods. Has anyone come up with a solution to closing views that can avoid this indirect reference?


Nov 15, 2010 at 8:20 PM


In a Prism application, views can be removed from any place if you have access to the RegionManager and the name for identifying a particular view. That said, you could avoid removing views from its ViewModel if you want.

For example in the Stock Trader RI, views are removed from a Controller class. If you need more guidance on this topic you could take a look at the following Reference Implementation Application: Stock Trader Reference Implementation, see the OrdersController class in the StockTraderRI.Modules.Position project.

Hope this helps.

Fernando Antivero

Nov 16, 2010 at 3:32 PM

Thanks for the insight Fantivero. Missed that overload :-) My MVVM impl in once again pure.