O'Reilly logo

MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF by Muhammad Shujaat Siddiqi, Ryan Vice

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dialog service

Dialog service is an approach where a layer of abstraction is used to show dialog boxes. View models delegate the responsibility of showing the dialogs to a dialog service and simply provide the service the data needed for display. The dialog service owns the responsibility of showing dialogs and we are able to keep our view models decoupled from System.Windows and avoid the need for references from our views to our view models. In unit tests, we can inject a fake dialog service instance instead of showing the actual dialog and use our fake object for stubbing and mocking.

Let's consider a simple example WPF MVVMLight project to show a dialog box using dialog service. The following view has a TextBlock and a Button. Clicking on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required