The "pretty" way to make a modal dialog in WPF with Prism and MVVM Pattern The "pretty" way to make a modal dialog in WPF with Prism and MVVM Pattern wpf wpf

The "pretty" way to make a modal dialog in WPF with Prism and MVVM Pattern


PRISM 5.0 came up with quick solution to show modal dialogs. Using PopupWindowAction.

<prism:InteractionRequestTrigger SourceObject="{Binding CustomPopupViewRequest, Mode=OneWay}">    <prism:PopupWindowAction>        <prism:PopupWindowAction.WindowContent>            <views:CustomPopupView />        </prism:PopupWindowAction.WindowContent>    </prism:PopupWindowAction></prism:InteractionRequestTrigger>


Interaction requests require a little more up-front work, but they are definitely the right way to go from the MVVM purist perspective...

I saw an example of how to do this with Prism in Karl Shifflett's MVVM In The Box training extension.

As I remember, the example was pretty rough around the edges, but it should set you in the right direction.

The problem with this kind of in-view "Dialog" is it doesn't allow the dialog to go outside the bounds of the parent window. On the plus side, you can do a lot of fancy layout and animation stuff.


check my post from here

its simple, its mvvm, its a service and "all you have to do" in your viewmodel is:

var result = this.uiDialogService.ShowDialog("Dialogwindow title goes here", dialogwindowVM);