Caliburn.Micro for instance, got an built in IEventAggregator
which allows you to create Eventmanagers which can be subscribed too. If you subscribe to this particular EventAggegrator with several ViewModels, you can define Messages that can be published and received from all ViewModels that have subscribed to this EventAggregator.
The following is just a short implementation and shows, how easy the communication between ViewModels can be, if you use a framework like Caliburn.Micro:
class ViewModel1 : PropertyChangedBase
{
private IEventAggregator _Event;
public ViewModel1(IEventAggregator events)
{
_Event = events;
_Events.Publish(new TestEvent(5));
}
}
class ViewModel2 : PropertyChangedBase, IHandle<TestEvent>
{
private IEventAggregator _Events;
public ViewModel2(IEventAggregator events)
{
_Events = events;
_Events.Subscribe(this);
}
public void Handle(TestEvent message)
{
// do something with the incoming message
}
}
class TestEvent
{
public int foo { get; set; }
public TestEvent(int someint)
{
foo = someint;
}
}
It should be pretty self explanatory. However, if you have any questions, please let me know and I will get into more detail.