Open 2 message boxes from 2 different modules at the same time

Topics: Prism v4 - WPF 4
May 24, 2012 at 5:21 PM


Please find a re-pro project at 

As you can tell in the project, I have 3 modules.  Orders and Products can be accessed from the buttons below or clicking on the links on the left hand side of the screen.

As you can see, each of the Orders and Product Modules have a button to launch a modal dialog.  Also, notice that I can not do anything once the modal dialog is launched.

I want to be able to launch a modal dialog from each module and be able to navigate back and forth between modules. 

Can you assist please.

May 24, 2012 at 7:36 PM
Edited May 24, 2012 at 7:36 PM


I have checked your repro-sample application and, based on my understanding of your desired scenario, it seems that this can be achieved by performing a couple of changes in your code. For example, you can declare the following popup regions:

<!-- In ProductView -->
<UserControl x:Class="Bish.Modules.Products.Views.ProductView"

<!-- In OrderView -->
<UserControl x:Class="Bish.Modules.Orders.Views.OrderView"

Navigate to the aforementioned regions in your view models:

// In ProductViewModel's ShowProductDetails method
_regionManager.RequestNavigate("ProductPopupRegion", new Uri(ViewNames.ProductDetailView, UriKind.Relative));

// In OrderViewModel's ShowOrderDetails method
_regionManager.RequestNavigate("OrderPopupRegion", new Uri(ViewNames.OrdersDetailView, UriKind.Relative));

And change the WindowWrapper's Show method to invoke the Show method of the window instead of ShowDialog (take into account that invoking the ShowDialog method of a window will make the Window modal for the entire application, not only the active view.)

However, this creates a new problem: each time you navigate to the views, the RegionPopupBehavior will try to create the aforementioned regions again. This can be avoided by changing the RegisterNewPopupRegion method to add an if statement like this:

IRegionManager regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
if (regionManager != null)
    if (!regionManager.Regions.ContainsRegionWithName(regionName))
        IRegion region = new SingleActiveRegion();
        DialogActivationBehavior behavior = new WindowDialogActivationBehavior();

        behavior.HostControl = owner;

        region.Behaviors.Add(DialogActivationBehavior.BehaviorKey, behavior);
        regionManager.Regions.Add(regionName, region);

After applying the aforementioned changes, you should be able to switch between the two views and invoke the two popups without problems.

What is left is how to disable the associated view when the popup is show. How to do this will depend mostly of your personal preferences. As an example, you could declare a boolean property in the view model and bind the view's IsEnabled property to this property. This property could be set to false when the popup is shown and set back to true when the popup is closed. Also, you could implement a more complex presentation logic (e.g. adding a gray overlay to the view) on the view's side by using DataTriggers.

As an alternative approach, if you wish to use InteractionRequests instead of RegionPopups, I believe you could find the following blog post useful:

I hope you find this useful,

Damian Cherubini

May 24, 2012 at 9:27 PM
Edited May 25, 2012 at 6:39 PM

Thank you so much again for your excellent support and prompt reply.  Unfortunatly, I tried this solution before on my own and it did not accomplish what I am looking for.

Once you make the changes you suggested, and run the application you will notice that you will end up with 3 windows, (the main application window, and the 2 modaless windows.  I can switch between the 2 views as desired.  The side effect I did not like, is that if I click to go back to one of the modules that has a child window open, the child window does not become (modal for the view), what I am trying to acheive is that when I switch, the child window will be brought to the front of the view becoming modal for that view. 

I tried to set the owner to be the view but that did not help, I hope my explanation makes sense.   I think the issue is that you can not set the "OWNER" on the window, it is always null.  

Any direction you can provide will be greatly appreciated.

May 29, 2012 at 9:01 PM


What I am trying to acheive in PRISM is similar to what Billy Hollis presented in in the first 10 min of this video, to give you and idea of what I am trying to acheive.

Thanks again, and looking forward to hearing from you again.


May 30, 2012 at 9:33 PM
Edited May 30, 2012 at 9:33 PM

Hi BishMan,

I have modified the repro-sample application you provided in this thread as an attempt to implement the functionality you described in this post. You can find the modified sample in my SkyDrive account:

Note that both the views and view models of the modules and the PopupBehavior's logic (WindowWrapper class, RegionPopupBehavior class, etc) had been modified to achieve this.

I hope this helps you as a starting point regarding your scenario.

As a side note, I have watched the video you mentioned above and I believe that it's important to mention that, based on my understanding, the "modal windows" shown in the video do not seem to be Windows, but overlay UI views styled to look like Windows that are put over the original view and handle the required events to react like a Window. As far as I know, this kind of scenario is not supported by Prism as out of the box.

In might opinion, this seems to be similar to the approach shown by Karl Shifflett in his In the Box - MVVM Training inside the Acme.MVVM.Scenarios sample:


Damian Cherubini

Apr 24, 2013 at 11:06 AM

How can I pass parameters to popup view using above code??
please help me..
Apr 24, 2013 at 9:28 PM

There are several code snippets and sample solutions posted in this thread. Which one are you referring to?
Also, there it could be useful to know a little more about your scenario so that we can have a better understanding about what you are trying to achieve.


Damian Cherubini