first_page

Inter-View-Model Communication

Previously, I saw only one way View Models exchange data: through Light Messaging. I think I’m seeing a second way: through service-locating (Microsoft.Practices.ServiceLocation``.``ServiceLocator). I regard service-locating as the imperative equivalent of the Locator static resource used in XAML declarations. With this regard, it follows that ServiceLocator is best for synchronous sharing of data (like getting a property value) and messaging is the choice for asynchronous sharing (service calls to the server).

The ObjectExtensions class that I was previously using for a certain category of MVVM Light Messaging has its members completely replaced with ServiceLocator routines (see pastebin.com code listing). In spite of the dangers of using static classes in certain automated testing scenarios, I currently prefer to use extension methods, handling ServiceLocator routines. This preference confines references to Microsoft.Practices.* in one area of the code base.

Related Links

https://github.com/BryanWilhite/