title: Can the MVVM-Light ViewModelLocator be used in nested ViewModels?
body: <p>The Visual Studio 2008 Designer doesn't seem to like UserControls that reference the MVVM-Light ViewModelLocator. I get an error message like:</p>
  
  <blockquote>
    <p>Could not create an instance of type 'MyUserControl'.</p>
  </blockquote>
  
  <p>For example, the following XAML will cause this behavior if MyUserControl uses the ViewModelLocator to establish its DataContext.</p>
  
  <pre><code>&lt;Page x:Class="MyProject.Views.MainView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:Views="clr-namespace:MyProject.Views"
  &gt;
      &lt;Grid&gt;
          &lt;Views:MyUserControl/&gt;
      &lt;/Grid&gt;
  &lt;/Page&gt;
  </code></pre>
  
  <p>MyUserControl is extremely simple:</p>
  
  <pre><code>&lt;UserControl x:Class="MyProject.Views.MyUserControl"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           DataContext="{Binding MyNestedViewModel, Source={StaticResource Locator}}"
  &gt;
  &lt;Grid&gt;
      &lt;TextBlock&gt;Hello&lt;/TextBlock&gt;
  &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>And the "MyNestedViewModel" property simply instantiates an instance of the MyNestedViewModel class, which has absolutely no code in its default constructor.</p>
  
  <p>Two questions:</p>
  
  <ol>
  <li>Am I using the ViewModelLocator correctly? That is, can it be used in nested views or is it only meant for top-level Views?</li>
  <li>Could this just be another bug in Cider, the Visual Studio 2008 designer?</li>
  </ol>
  
  <p>Note that everything works perfectly at runtime. I only have problems at design time. But I hate coding XAML blind.</p>