Urgent help needed with Multiple Shell configurations in Prisim 4

Topics: Prism v1, Prism v2 - Silverlight 2, Prism v2 - Silverlight 3, Prism v2 - Silverlight 4, Prism v2 - WPF 3.5, Prism v2 - WPF 4, Prism v4 - Silverlight 4, Prism v4 - WPF 4
Jun 23, 2010 at 7:49 AM
Edited Jun 23, 2010 at 5:36 PM

I have a composite application that consists of around eight modules which in turn are each tied to two shells. 

My issue is I do not have any idea on how to switch from one shell to the other on the fly.  Only one shell i.e. SHell1 should be visible at a time

So if the user clicks on the shared navigation ribbon to access a module that is in Shell 2.  Shell 1 should close and open up shell 2.  That way I can also

Create custom splash pages etc.

So to cut a long story short I need some guidance on how to activate/deactivate a Shell.  I am using the MVVM pattern as well with view models for all my shells and modules.

How can I switch shells from each Shell’s individual view model , or do I have to do something with bootstrapper and basically load both shells at once and then use the hide/show method as needed ?

Basically I am very new to Prism and modular applications as you can see so some detailed examples or even code snippets would be useful.


Jun 25, 2010 at 8:58 PM


A possible approach, as you’ve mentioned, is to load both shells in the Bootstrapper, and then use the Hide and Show methods when needed. Based on Damian Shenkelman’s blog post, I’ve created a sample application to exemplify how to achieve this, which you can download from here.

There are a couple of things worth noting about this sample:

  • The most important parts that may help you understand this are the CreateShell method inside the Bootstrapper.cs class and the ShellViewModel.cs class.
  • I’ve used the Event Aggregator to publish an event from a shared module (which in your case would be the ribbon one). The ShellViewModel subscribes to that event, and performs the necessary operations to hide and show the shells accordingly.
  • I’ve used Delegate Commands for the shell switching buttons, but you don’t necessarily have to use them to achieve this scenario.
  • In Damian Shenkelman’s sample, the ShutDownMode is set to OnLastWindowClose, but since you specified that only one shell should be visible at a time, I’ve set it to OnMainWindowClose, and define the current shell as the MainWindow of the application each time the shells are switched. That guarantees that the application will shut down when the current shell is closed.

I hope you find this helpful.

Guido Leandro Maliandi