Good or bad practice for Dialogs in wpf with MVVM?

This is a good approach and I used similar ones in the past. Go for it!

One minor thing I’d definitely do is make the event receive a boolean for when you need to set “false” in the DialogResult.

event EventHandler<RequestCloseEventArgs> RequestCloseDialog;

and the EventArgs class:

public class RequestCloseEventArgs : EventArgs
{
    public RequestCloseEventArgs(bool dialogResult)
    {
        this.DialogResult = dialogResult;
    }

    public bool DialogResult { get; private set; }
}

Leave a Comment