Display a messagebox from the ViewModel using Prism’s InteractionRequests
Posted by coreclr on January 5, 2011
Prism has a nice feature called InteractionRequests. We can use this when the view-model needs to initiate an interaction, like displaying a messagebox.
Below is a simple example:
In XAML I define the PopupChildWindowAction to display the dialog to the user. The visuals of this dialog is defined in the SaveWindowsTemplate.
The magic here is the InteractionRequestTrigger from Prism. I set the SourceObject to the SaveRequest that is defined in the ViewModel.
SaveRequest is a InteractionRequest that define a Raise method, that we can use to raise the event.
I then use a interaction trigger to call the Cancel method in the viewmodel. See Preview post.
And the result look like this:
Leave a Reply