O'Reilly logo

Microsoft Silverlight 5 Data and Services Cookbook by Kevin Dockx, Gill Cleeren

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Communicating between different ViewModels

Applies to Silverlight 3, 4, 5 and WP7

Often, you'll find yourself in need of sending messages between ViewModels. A very typical example would be: you've got a View with a ListBox, and once an item is selected, you want that item to be displayed in detail in another View. In other words, the standard master-detail requirement.

How do you achieve this with MVVM? If you didn't follow the pattern, you could easily say: "well, I need to execute a method on ViewModel B when something happens in ViewModel A, so I'll keep a reference to ViewModel B in ViewModel A, so I can call the method when appropriate". This, of course, is tight coupling—your ViewModels aren't independent of each other anymore, and ViewModel ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required