Reputation: 3105
ViewModelA:
inside its constructor (breakpoint hits the foll. line):
Messenger.Default.Register<int>(this, "token", OnHitIt);
ViewModelB:
breakpoint does hit this line:
Messenger.Default.Send(hitItId, "token")
But for some reason breakpoint never hits OnHitIt method, what could be the reason...
Upvotes: 0
Views: 2189
Reputation: 2563
Try using
On ViewModelA:
Messenger.Default.Register<NotificationMessage<int>>(this, OnHitIt);
And the OnHitIt method would be-
private void OnHitIt(NotificationMessage<int> m)
{
if (m.Notification == "token")
{
// code goes here
// m.Content will get the int passed in
}
}
On ViewModelB:
Messenger.Default.Send(new NotificationMessage<int>(hitItId, "token"));
Upvotes: 1
Reputation: 21098
One reason would be that ViewModelA is no longer referenced by anything, but more likely it's that token look-up is is by reference and not by value. In other words "token" in the Register is not the same reference as "token" in the Send.
Upvotes: 0