Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVVM Light Messenger Not Functioning As Expected

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?

like image 547
DanteTheEgregore Avatar asked Jul 10 '26 07:07

DanteTheEgregore


1 Answers

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.

like image 110
dm88 Avatar answered Jul 11 '26 22:07

dm88