A while back I asked a question found here: Use MVVM Light's Messenger to Pass Values Between View Model
I went to test the answer today and it doesn't appear to be working. My implementation looks as follows:
MessengerInstance.Send(SelectedDocument, Model.StaticEnums.Tokens.SettingstoMain);
And:
MessengerInstance.Register<XDocument>(this, Model.StaticEnums.Tokens.SettingstoMain, settings => CopySettings(settings));
My problem is, this implementation doesn't work. Instead, the arguments for MessengerInstance.Send and MessengerInstance.Register both appear to be strikingly different from the implementation in the answer.
What am I doing wrong here? Is the implementation in the answer to my previous question correct?
I didn't worked a lot with MVVM light in the past few months. But I send and registered messages always this way (see code). Maybe there are better ways in the new version. But I don't think.
GalaSoft.MvvmLight.Messaging.Messenger.Default.Register<string>(this, (a) => { MessageBox.Show(a); });
GalaSoft.MvvmLight.Messaging.Messenger.Default.Send<string>("abc");
Make sure that you first REGISTER the message before you send it.
EDIT: For each message type I created a custom message class. So it's easier to find in the code where the message is used in the application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With