You can use Messenger to do this: Send the user to UserViewModel:
Messenger.Send<User>(userInstance);
just send the user to everyone who is interested.
And register the recipient in CardViewModel:
Messenger.Register<User>(this, delegate(User curUser){_curUser = curUser;});
or you can also send a request from your CardViewModel in order to shout out the user:
Messenger.Send<String, UserViewModel>("Gimme user");
And respond to this in the UserViewModel:
Messenger.Register<String>(this, delegate(String msg) { if(msg == "Gimme user") Messenger.Send<User>(userInstance); });
(It is better to use an enumeration rather than a string in a real scenario :))
Perkhubs you can even answer directly, but I can not check it at the moment.
Just check it out: mvvm light messenger
CodeWeasel Apr 23 '10 at 16:40 2010-04-23 16:40
source share