Blendability of nested view models with MVVM Light

Apr 13, 2010 at 1:20 AM
Edited Apr 13, 2010 at 3:12 PM

So, lets say I have a viewmodel collection in my main window model, what is the "proper way" to ensure blendability, and still have it cleanly seperated layers? So far I came up with this:

Have an Observable Collection of viewmodels, 

Have MainWindow.xaml reference "ViewMapping.xaml" which contains typed data templates like:


<DataTemplate DateType="{x:Type ChildViewModel}">




Have it's host (MainWindow) have a design time data model for it to use.  Is this the best way? or is using the locator better?  If so, how should the locator be used in this scenario?  MVVM Light newbie here!


Apr 18, 2010 at 9:24 PM


This way of doing is used quite often in WPF. It does not however work in Silverlight. This is the main reason why I do not use this code, in order to keep the XAML compatible.

Hope this helps,


Apr 18, 2010 at 9:33 PM
Edited Apr 18, 2010 at 10:21 PM

So then what is the preferable way of doing this? Also, why is this approach incompatible with SL?

refer to: 

Thank you for the response.

Apr 18, 2010 at 9:59 PM

The approach is incompatible with SL because the implicit typing functionality that you use in the DataTemplate here is not implemented in Silverlight. It's one of these features that exist in WPF but not in SL (yet...).

My preferred approach, as I answered on the StackOverflow thread, is to use the ViewModelLocator for child viewmodels too.

Hope this helps,


Apr 18, 2010 at 10:22 PM

It does indeed,  to close the discussion thread, I will post an implementation as you describe it in the near future for the benefit of others.


Apr 19, 2010 at 9:09 AM


Great, let me know when you have it, and I will add it to the Get Started page as documentation.



Nov 29, 2013 at 1:39 AM
Just out of curiosity, since Silverlight-5 has data-template, is the preference to use them? Seems it would be much simpler than using the VM Locator, and for whatever reason in my mind I can't envision how this would work with the VM Locator, unless it involves also using the messenger service. Anyone care to elaborate about how you can use the VM Locator for an observable collection of vm's?