Neat MVVM – Enums for tokens as flags

Neat MVVM Light tool for the belt – Enums for tokens as flags Enums for tokens allows for Generic calling.

//One of the great things about Mvvmlight, the Messenger 🙂 you could to object and .ToString() in this method too.

public static void SendTo(this string input, MessengerToken token){

Enum.GetValues(typeof (MessengerToken)).Cast<MessengerToken>().ToList().Where(e => token.HasFlag(e)).ToList().ForEach(e =>


Messenger.Default.Send<string>(input, e);});



Add in the Flag Based Enumerator with the Enum Extension Methods :


And you can call many Messenger sends in one swoop.

DoOuputActionPreFormatting(e.Result.Text, (s) =>


   s.SendTo(MessengerToken.MasterText | MessengerToken.MainRegion);



/// You can send to more than one spot at one time.

/// Set your Enum to MainRegion | MasterText to sent to both 🙂



public enum MessengerToken


[Description(“”)] ByType = 0,

[Description(“Main Region Text”)] MainRegion = 1,

[Description(“Master Text”)]MasterText = 2,


Share on Facebook

Leave a Reply

Your email address will not be published.