How do I make a utility dialog globally available?

Topics: Prism v4 - WPF 4
May 10, 2012 at 9:41 AM

I need to create a utility modal dialog to prompt users to select items from a list and return the list of what was selected - returning a csv string would be fine.  The dialog needs to be available to multiple modules in the prism application.

How can I define this dialog only once yet make it available to all the modules without duplicating code?

Gary

Developer
May 10, 2012 at 10:02 PM

Hi,

I believe a possible approach to achieve showing dialog windows like you mentioned could be using Interaction Requests. You will find that the Prism library provides many examples and  documentation on this subject.

In particular you could find useful information about this in the following section of the Prism documentation:

Although, as mentioned in this thread, currently all demo applications provided with Prism as out of the box are related to Silverlight, but an useful example of Interaction Requests with WPF applications can be found in the following training kit:

Take into account that different triggers and actions can be defined to support different interaction mechanisms. The implementation of the Prism InteractionRequestTrigger and PopupChildWindowAction classes can be used as a basis for the development of your own triggers and actions, which will depend mostly on your personal preferences and the requirements of your scenario.

Recently, I created a blog post regarding Interaction Requests with WPF. You could find it here:

Based on the sample in this blog post, I also created an example on how these interactions can be used to achieve scenarios like the one you mentioned. You can find it in my skydrive account under the name "CustomPopupModalWindowAction".

I hope you find these useful,

Agustin Adami
http://blogs.southworks.net/aadami

May 11, 2012 at 10:10 PM

hello,

Based on your example, if I want to create a modal dialog for the user to edit/add new record for example?  The modal dialog will need to take a view and view model so I can do all the things I need in there, and every module in my application will have to use this with its' unique view and viewmodel.

How do I accomplish this with the above example you provided please?

 

 

Developer
May 14, 2012 at 6:15 PM

Hi BishMan,

Based on my understanding of your scenario, if you want to be able to show views with their corresponding view models according to the task performed by each module, I believe the WindowDialogActivationBehavior provided in the Stock Trader RI would be more suitable. This behavior simply defines a region so that when a view is injected in it, the region with its view will be shown in a new window. Therefore, you would be able to inject any view you need. Also, if you need to pass data between the parent and dialog views / view model, you can achieve this through different communication approaches like using the EventAggregator or a shared service. Take into account that the implementation details for this will depend mostly of your personal preferences and the requirements of your scenario.

As a side note, by default the WindowDialogActivationBehavior provided in the Stock Trader RI does not show a dialog window; however, this can be changed by replacing the following line in the Show method of the WindowWrapper class:

this.window.Show();

With this one:

this.window.ShowDialog();

You can find more information about this and a small sample portraying this approach in the following thread:

I hope you find this useful,

Damian Cherubini
http://blogs.southworks.net/dcherubini

May 24, 2012 at 3:38 PM

Hello,

Thank you so much for your reply, but this will not address my issue.  I would like to open 2 dialog boxes from 2 different modules at the same time.

How can I accomplish this please.

Developer
May 24, 2012 at 6:36 PM
Edited May 24, 2012 at 6:41 PM

Hi,

As it seems that you have created a new thread regarding this topic, I believe it would be helpful to continue the discussion in that thread:

Regards,

Damian Cherubini
http://blogs.southworks.net/dcherubini