Chapter 7. Dialogs and MVVM
By Muhammad Shujaat Siddiqi
In WPF, dialogs are similar to those in Winform. The only way to show dialogs is by using either Window.Show() (modeless) or Window.ShowDialog() (modal) methods.
Note
This includes built-in dialogs, such as MessageBox, OpenFileDialog, SaveFileDialog, and PrintDialog.
Since we need our view model logic to be able to initiate the display of these dialogs, we might be tempted to call these methods directly from our view models. The problem with calling Show() or ShowDialog() directly is that it requires the System.Windows.Window references to be held by view model coupling ViewModel to System.Windows. This breaks down the desired separation of concerns in MVVM and makes things like testing our ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access