How do you troubleshoot when Messenger Register not firing Action?
In code behind for a page:
Messenger.Default.Register(this, CheckWaitState);
and
private void CheckWaitState(string message) { //do something with message }
when a view model fires this:
Messenger.Default.Send(new NotificationMessage(开发者_StackOverflow中文版"", "some message..."));
...the above code is not hit. How do I troubleshoot?
Thanks
You're registering for a message of type 'string' but sending a message of type 'NotificationMessage'.
Try this:
Messenger.Default.Register<NotificationMessage>(this, CheckWaitState);
private void CheckWaitState(NotificationMessage message)
{
//do something with message.Notification
Console.WriteLine(message.Notification); // outputs "some message..."
}
Messenger.Default.Send(new NotificationMessage("", "some message..."));
精彩评论