I am using mvvm light on my project. For communication between view, I am using GalaSoft.MvvmLight.Messaging.Messenger but it does not work as expected.
The code below:
Register a messenger
GalaMessenger.Default.Register<ServerNewMessenger>(ServiceLocator.Current.GetInstance<ServerNewViewModel>(), (msg) =>
{
Debug.Write("Click");
});
Send messenger to receiver
Messenger.Default.Send<ServerNewMessenger>(newItem, ServiceLocator.Current.GetInstance<ServerNewViewModel>());
I never receive the message. But when I remove the recipient by the send method:
Messenger.Default.Send<ServerNewMessenger>(newItem);
Then it works fine. Why?
GetInstancereturn a different instance on each call? - Patrick QuirkGetHashCode()and it shows me the same code, that means it points to the same object. - softshipper