IDialogService.ShowDialog and IDialogService.Show are the non-generic methods where the dialog type isn't specified in the method call. Specifying a dialog type in a view model might either be unwanted or impossible in certain situations, thus the framework supports opening a dialog without specifying the dialog type. Implicit dialog type syntax and the dialog type locator For them there is the implicit syntax and the dialog type locator. The MVVM purists among the readers are most certainly appalled by the fact that the view type is defined in the view model. The most straight forward syntax to use is the explicit syntax where the generic methods IDialogService.ShowDialog and IDialogService.Show shows a modal respectively non-modal dialog of the type T. Both concepts and the difference in usage is described in the upcoming chapters. Showing a dialog can be performed in either of two ways, either by explicit specifying the dialog type or by implicit using the dialog type locator.
MVVM LIGHT VISUAL STUDIO 2015 CODE
A modal dialog halts code execution and awaits the dialog result while a non-modal dialog continues code execution without waiting for any dialog result. Showing a dialogĪ dialog can be shown either as modal or non-modal. This chapter will demonstrate the code required to show the supported WPF dialogs. More interesting than the implementation of the framework is the usage of it, so lets start with that. The framework has built in support for opening the following dialogs: The only extra benefit you'll get is the ability to easily write unit tests for your view models in the same manner unit tests are written for other classes. It doesn't contain any fancy view model base classes, nor any event broker or service locator. It does a pretty good job of that but nothing else. It is designed to simplify the concept of opening dialogs from a view model when using MVVM in WPF or UWP. This framework is not a complete all-inclusive MVVM framework. There already exists numerous MVVM frameworks, and for those looking for a more complete solution to MVVM I would recommend taking a look at the following frameworks:
Josh Smith has written a fantastic article in MSDN Magazine which can serve as the starting point for those that are unfamiliar with the pattern. Basic knowledge of the pattern is expected.
This article will address one of the problems you might run into when using the MVVM pattern, namely opening dialogs from view models. Showing single and multiple file pickers.