Applies to Silverlight 3, 4, 5 and WP7
One of the first things you'll have to decide on when working with the MVVM design pattern is how you're going to connect your Views to your ViewModels. The simplest method by far is by just instantiating the ViewModel in the View's constructor, but this of course breaks the idea that we're trying to work as loosely coupled as possible (even though a View and ViewModel are somewhat coupled by design, as a ViewModel needs to have the properties used in the View's binding syntax).
The approach used in MVVM Light is that of the
ViewModelLocator. In this recipe, we'll learn how to use this
ViewModelLocator to tie your View and ViewModel together.