obaylis
obaylis

Reputation: 3034

WPF interactionRequests in PRISM

I have what, on the face of it, seems to be a really simple requirement - to be able to show a messagebox from within the view model of my WPF prism application.

Reading the documentation everything sounds good when I'm reading about Interaction Requests but I then find out that WPF doesn't support PopupChildWindowAction.

How are people getting around this. Basically I want a Messagebox in my shell module / or a infrastructure module that will subscribe to events and popup when that event is published.

Another issue I had was I want the popup to be centered on the parent window (the shell).

Just wondered how other people approached this. There seem to be a number of different ways to go but neither seem to fit the bill exactly.

Upvotes: 2

Views: 2696

Answers (4)

Gerald G.
Gerald G.

Reputation: 81

Since PopupChildWindowAction is only in Silverlight, I have created my own PopupAction by inheriting from TriggerAction class and simply overridden body of Invoke() method to bring up a PopupWindow where I can pass any UserControl from xaml within the prism interaction trigger tag. From within ViewModel I am raising interactivity request event which triggers my PopupAction in view and opens the popup with desired user control being displayed onto it. Seems to work. I'll need to polish the example more. But here is a link -

http://wpfgrid.blogspot.com/2013/01/simple-prism-mvvm-way-to-display-dialog.html#step3

Upvotes: 0

Ron Clarke
Ron Clarke

Reputation: 71

From A CodePlex post by Karl Shifflet:

I've written a WPF version of the Interaction Request for my the Box MVVM Training here:

http://visualstudiogallery.msdn.microsoft.com/en-us/3ab5f02f-0c54-453c-b437-8e8d57eb9942

Install this Visual Studio Extension.

Create a new project with the MVVM Training Template.

Check out DialogInteractionRequestView.xaml and its implementation.

Cheers,

Karl

Upvotes: 4

Damian Schenkelman
Damian Schenkelman

Reputation: 3535

Use the RegionPopupBehavior from Prism 2.2 RI.

Upvotes: 0

Oppositional
Oppositional

Reputation: 11211

Use the EventAggregator in PRISM to subscribe to events, and have an in-memory presenter that listens for an event and then creates a view using the event data and calls ShowDialog on the view.

The dialog result can then be used to publish a 'response' event that would be routed back to the process that initiated the event that resulted in the display of the dialog.

Upvotes: 0

Related Questions