Shell switching using MEF

Topics: Prism v4 - WPF 4
Aug 21, 2011 at 8:46 AM


I am new to prism an i am looking to use this framework as startpoint for a new project that i am working on. Allmost on the start i came upon an obsticle that i can not come over it. I'll try to explain I have a "dashboard shell" and a "working shell" on user login/logout i switch between them... i have the login services and views in a seperate module. The problem i encounter is that when i initialize the login module i register it's views with appropriate regions in both shells. when i execute the login first time on the dashboard shell and switch to the working shell it's all ok. During logout from working shell i switch back to the dashboard shell but in this proccess the view for logout is removed from the dashboard shell. and that is my problem. in the dashboard shell i have two views login and logout when i statrt the app it looks ok. after first switch of shells the dashboard shell contains only login view.


I have the source code on my skydrive (


Pleace help me.



Aug 23, 2011 at 8:00 PM


You could try decorating your class with the following attributes:

public partial class LogoutView : UserControl

public partial class LoginView : UserControl

Note that by default types registered with MEF are singletons. To avoid this you must set the PartCreationPolicy NonShared.

 I hope you find this helpful.

Agustin Adami

Aug 24, 2011 at 6:29 PM



Thank you for your reply. It was helpful. I have a diferent problem now on the road... Can you pleace point me to the right dirrection on modal dialogs in prism 4 for WPF. I am lookin for some kind of a "service" implementation. I want the same sub system for the interaction with the user (exeptions, interactinos, ect..) I you would be so kind an help me a bit on this problem i would be verry gratefull.


Aug 24, 2011 at 7:50 PM
Edited Aug 24, 2011 at 8:14 PM

Hi Slavko,

To implement a modal dialog in Prism you can check the code of the Stock Trader Reference Implementation, which uses a behavior (PopupDialogActivationBehavior.cs in the silverlight version and WindowsDialogActivationBehavior.cs in the desktop version) to show a view in a new window. You can modify the code of these behaviors to show the view in a modal dialog instead of a window.

Also, you can check the MVVM Training - In The Box by Karl Shifflett which shows an interesting approach for the implementation of a kind of modal window without the use of a synchronous modal dialog, which provides the possibility to interact between the modal window and the main application.

I hope you find this useful,

Damian Cherubini