In this video, I answer the question “How do I show Dialogs in an MVVM application?”

Showing dialogs in an MVVM application is a very common requirement. MVVM dialogs are actually core to any MVVM application. In this video, I show you how to use an MVVM Dialog Service to abstract away the process of creating and showing dialog objects from within a ViewModel.

The first step in showing dialogs in an MVVM application is to create an interface that defines your Dialog Service. For example

public interface IDialogService 
{ 
    void ShowDialog();
} 

Next you need to create a class that implements your MVVM Dialog Service.

public class DialogService : IDialogService
{
    public void ShowDialog()
    { 
        ...
    }
} 

Once created you would use this service in your ViewModel to show your MVVM dialogs

IDialogService dialogService = new DialogService();
dialogService.ShowDialog();

In this video, I will walk you through each step reuired to implement a proper MVVM Dialog Service. We will cover: -Creating the MVVM Dialog Service
– Showing dialogs using names
– Handling Dynamic Dialog Window content
– Responding to closing the Dialog within your ViewModel
– Passing data to your ViewModel when you close the dialog
– Registering ViewModels with your Dialogs
– Showing dialogs using a ViewModel Type instead of a name

Be sure to watch my new Pluralsight course “Introduction to Prism for WPF”:
📺 http://bit.ly/PrismForWpf

Sponsor Me on GitHub:
🙏🏼 http://bit.ly/SponsorBrianOnGitHub

Follow Me:
🐦 Twitter: http://bit.ly/BrianLagunasOnTwitter

Brian Lagunas

View all posts

Follow Me

Follow me on Twitter, subscribe to my YouTube channel, and watch me stream live on Twitch.