This project is read-only.

Pass a parameter with the Messenger class

Apr 5, 2013 at 10:04 AM
Hi,

I use the MVVM Foundation Messenger class to communicate between my ViewModels. This works fine.
How ever I would like to pass a parameter to it as well but I can't find how to retrieve it.
 ViewModelCommunication.Messaging.NotifyColleagues(ViewModelCommunication.LogInChanged, "TEST");
The parameter is here the string "TEST". How do I retrieve it in the registered ViewModel?
ViewModelCommunication.Messaging.Register(ViewModelCommunication.LogInChanged, param => { this.aProperty = (string)param; });
This doesn't work. I guess it is simple but I can't find it. Does someone have an example?
Apr 5, 2013 at 10:17 AM
Found it:
ViewModelCommunication.Messaging.Register(ViewModelCommunication.LogInChanged, (Action<String>)(param => { this.Test = (string)param; }));
This fills my property Test with the value "TEST".