Modal Dialog

Nov 17, 2011 at 12:44 PM

Hi List,

what i try to do:

Use the prism:interactionrequest to show a UserControl with the related ViewModel as a Modal Dialog.

All what i can find are examples of Confirmation and Notification.

Any idea?



Nov 17, 2011 at 5:52 PM

Hi Peter,

As a possible approach to achieve this you could create a Child Window control that would be your modal dialog and extend the PopupChildWindowAction provided by Prism to implement you own custom logic about how information from the view is going to be sent to the Child Window control.

The implementation details of this depends mostly of your personal preferences and the requirements of your scenario. As an example, you could extend the PopupChildWindowAction doing something like this:

public class CustomPopupChildWindowAction : PopupChildWindowAction
      protected override ChildWindow GetChildWindow(Notification notification)
           var dataContextAsINotification = this.ChildWindow.DataContext as Notification;

           if (dataContextAsINotification == null)
               this.ChildWindow.DataContext = notification;
               dataContextAsINotification.Content = notification.Content;
               dataContextAsINotification.Title = notification.Title;

           return this.ChildWindow;

Where, if the view model of the Child Window control inherits from Notification, its Content and Title properties are set. If not, the Notification object it self is set as the data context of the Child Window control. Also, in this example we assume that the Child Window control has a constructor without parameters where the view model is obtained though the Service Locator.

Then you can use this Child Window control in you view doing something like this:


<prism:InteractionRequestTrigger SourceObject="{Binding SubmitErrorInteractionRequest}">

Also, as an alternative approach that doesn't involve interaction requests, you might find the WindowDialogActivationBehavior and PopupDialogActivactionBehavior include in the Stock Trader RI useful.

I hope you find this useful,

Damian Cherubini


Nov 17, 2011 at 9:29 PM

Hi and thanks a lot for the answer.

But, i think i'm to stupid to understand them.

My i ask you for a  small sample where the childwindow hold for exampe only a ListView...

Thnks in advance



Nov 18, 2011 at 5:30 PM

Hi Peter,

You can find a sample (based on the Hello World QuickStart) uploaded in the following link with the name CustomPopupChildWindowAction:

In the sample, the HelloWorldView has a button with a binding to a command in its view model, which simply raises an interaction request. This view has an interaction trigger which uses the CustomPopupChildWindowAction (which you can find in the Infrastructure project) to show the CustomDialog child window as a modal dialog.

I hope you find this useful,

Damian Cherubini

Nov 18, 2011 at 7:30 PM
Edited Nov 18, 2011 at 7:32 PM

Thanks a lot,

the example give me the light *g*

Many Thanks


Apr 9, 2013 at 4:36 PM
@DCherubini, First of all : Thanks a lot for your work. I am still in your steps and i find it so great.

For me your sample PopupWindowAction for WPF works just fine.
But i am trying to make working the sample CustomPopupChildWindowAction for Silverlight
with Prism v4.1 and Silverlight 5.0
and In HelloWorldModule\Views\HelloWorldView.xaml i get an error :
Says :

A value type of "InteractionRequestTrigger" cannot be added to a collection or a dictionnary of type "TriggerCollection".

Well if you have an idea ... I will digg ...

I am still asking myself WHY wpf and silverlight frameworks seams are so identical and if so different.

Apr 9, 2013 at 5:27 PM
Edited Apr 9, 2013 at 6:29 PM
Mabyre wrote:
Ok I get my mistake, i did not install Blend for Silverlight Grrrrrrr !
My blog in french C# .NET Blog