Categories
Xamarin

Moving from MvvmLight to Microsoft Mvvm Toolkit – Messaging

I recently needed to rework an existing Xamarin project and replace the MvvmLight implementation with the new Microsoft Mvvm Toolkit. This is generally an easy process and it has been designed as the spiritual successor to Laurent’s library.

One area which had more changes was the Messaging namespace where the app had made use of some built-in messaging types which have no direct equivalent in the Microsoft library. Faced with the issue of further changing the app or simply reimplementing the MvvmLight functionality for the Mvvm Toolkit I chose the latter approach and created an equivalent NotificationMessage class which I’ve put into a Gist in case it is handy for anyone else.

namespace Microsoft.Toolkit.Mvvm.Messaging.Messages
{
public sealed class NotificationMessage<T>
{
public NotificationMessage(T content, string notification)
{
Content = content;
Notification = notification;
}
public T Content { get; }
public string Notification { get; }
}
}

By Peter Foot

Microsoft Windows Development MVP