About using messenger of mvvmlight v4, I have a questions: Where should we put the register of Messenger? I sought out some examples, they put them in constructor of view. But I got a problem with that, anytime we create an instance of view, this message is registered again --> the message handler will be invoked as the same number of registered message.
Such as: I register a message like:
Messenger.Default.Register<NotificationMessage>(this, (nm) =>
{
if (nm.Sender == this.DataContext)
{
if (nm.Notification == "OnNext")
{
this.Hide();
Form2 f2= new Form2();
f2.Show();
}
}
}
--> Everytime, 1st time user clik Next, 1 form appears, but when user click Next again, this time, 2 messages were registered & make 2 forms appear. How can I handle this case?
Thanks in advance for any help of you.