Handling Dialogs in WPF with MVVM

Posted by Ray Booysen on Stack Overflow See other posts from Stack Overflow or by Ray Booysen
Published on 2009-01-18T09:23:11Z Indexed on 2010/03/11 21:34 UTC
Read the original article Hit count: 232

Filed under:
|
|
|
|

In the MVVM pattern for WPF, handling dialogs is one of the more complex operations. As your view model does not know anything about the view, dialog communication can be interesting. I can expose an ICommand that when the view invokes it, a dialog can appear.

Does anyone know of a good way to handle results from dialogs? I am speaking about windows dialogs such as MessageBox.

One of the ways we did this was have an event on the viewmodel that the view would subscribe to when a dialog was required.

public event EventHandler<MyDeleteArgs> RequiresDeleteDialog;

This is OK, but it means that the view requires code which is something I would like to stay away from.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about dialog