Deprecating the DialogMessage
One change you will notice when you install MVVM Light V4.3.31 is that I marked the DialogMessage class as Obsolete.
The DialogMessage class is one of the built in message classes in the MVVM Light Messaging namespace. When sent by the Messenger to a view element (Window, Page, etc), it carries information that can be used by the recipient to display a message to the user. It also has a callback to pass the result (OK, Cancel, etc) back to the caller for handling.
DialogMessage is an old class from MVVM Light, it was already there in the first versions, when the toolkit was only available for WPF. It has a few “youth issues” because of that, and if I had to do it again, I wouldn’t include this class anymore. The main issue with it is that it uses “view enumerations” such as MessageBoxButton and MessageBoxResult. In fact, because of these issues I removed DialogMessage from the Windows Store version of MVVM Light already. The differences between WPF, Silverlight and Windows Phone/Silverlight on one hand, and Windows Store on the other hand are too big and made this class unmanageable. As a result, this breaks cross platform compatibility when you want to use your viewmodels in Windows Store apps too.
Marking the class as obsolete means that you should transition to another implementation. I prefer the “dialog service” implementation to display messages to the user and pass the result to the caller. More information about the IDialogService implementation as well as a sample can be found in one of my MSDN article magazines.
Coming up soon I will publish a cross platform implementation of DialogService which I use on various platforms, including Xamarin. It’s not quite ready yet, and I want to spend more time on this first. For now, you don’t need to worry too much about the Obsolete warning, as the DialogMessage class will continue to work like before. Eventually however, it will be removed from MVVM Light.
Stay tuned to my Twitter feed and to this blog for announcement when the cross platform DialogService sample will be ready.
Happy coding
Laurent