I would recommend that you read-up on the Messaging system in the MVVM light toolkit. This seems to be the simplest approach I have found to accomplishing this. Here is an example of how it works:
If you have 2 view models - 1 for searching customers, the other for display details about the selected customer:
In first view model, you have a property such as this:
public string CustomerID
{
get
{
return _customerid;
}
set
{
if (_efolderid == value)
{
return;
}
var oldValue = _customerid;
_customerid = value;
// Update bindings and broadcast change using GalaSoft.MvvmLight.Messenging
RaisePropertyChanged("CustomerID", oldValue, value, true);
}
}
Then, in the second view model, you register to recieve messages when this value changes from the other, such as this:
void registerForMessages()
{
Messenger.Default.Register<PropertyChangedMessage<string>>(this,
(pcm) =>
{
if (pcm.PropertyName == "CustomerID")
{
customerID = pcm.NewValue;
AddWorkplanCommand.RaiseCanExecuteChanged();
loadCustomerDetails();
}
});
}
Be sure to call your registerForMessages() function in the constructor of the second view model. Another thing that helps is to create a map of sorts when you have 4 or more ViewModels in your application. I find is easy to construct one in a quick text file in the solution to keep track of all the messages and what they are intended to accomplish, and which other view models are registered to recieve them.
One of the really nice things about this is that you have have 1 viewmodel send a change notification, such as the customerID property changed, and immediately have 4 other viewmodels recieve that change and all start loading changes themselves.