I know there are many questions regarding how a ViewModel should open a dialog box, how does the Model launch dialogs?
Should the model call a dialog service, that call the viewmodel’s dialog service, all the way up to the view? Should the model have a reference to the mvvm-light toolkit?
Specifically for my situation – when my model is passed some data to restore / interpret and build model objects (I think this should be the model’s job) – there is potential for errors to be raised.
Update #1: I’ve accepted the answer below, based on the comments from fmunkert. I’ve realized that I was asking the wrong question, and the fundamental problem is designing a paradigm for the model to signal errors.
Since MVVM is not a standard and since there is no definitive authority that decides what is correct in MVVM and what is not, you can implement dialog boxes in any way you see appropriate, as long as you do not call any WPF dialogs directly from the ViewModel or model.
In the applications I recently wrote, I used the following two approaches (with my own MVVM framework library):
Modal dialogs are called from the ViewModel via a “service”. I.e. the ViewModel has a way to obtain an
IFrontendpointer with aShowModalDialog()method. There are two generic implementations forIFrontend: one for WPF (which opens a dialog) and one for the unit test environment (which just simulates a dialog).Non-modal dialogs sometimes can be opened without the ViewModel knowing about them. E.g. if you have a ViewModel for a form where you need to be able to open a font selection dialog, then this is a user interface detail and the ViewModel does need to know about that detail. The ViewModel does not care whether the font is selected using a dialog or using a drop-down list.
If you are using third-party libraries like MVVM Light or Prism, you probably should follow the recommendations from the library’s documentation.