Add a global message queue that will receive and foward messages from (view)-models to (view)-models.
Example:
LoginViewModel.cs
public class MainViewModel : Sender<T>, ...
{
public void LoginAction()
{
// send message of type T to any other VM
base.Send(new { User = this.User, Status = Status.LoggedIn });
}
}
MainViewModel.cs
public class MainViewModel : Receiver<T>, ...
{
public override void Receive(T message)
{
// received message of type T from another VM
}
}
Receiver can optionally also handle whether the message gets removed from the global message queue or stays untouched.
This is especially useful for multi-view applications, where extra updates are needed upon some action.
Use case:
Application has an all-users window and a create-new-user window.
New user gets created
All-Users window gets updated with the newly created user
Add a global message queue that will receive and foward messages from (view)-models to (view)-models.
Example:
LoginViewModel.cs
MainViewModel.cs
Receiver can optionally also handle whether the message gets removed from the global message queue or stays untouched.
This is especially useful for multi-view applications, where extra updates are needed upon some action.
Use case: