title: Setting datacontext of UserControl to ViewModel defined in parent viewmodel
body: <p>I'm trying to create an application using the MVVM pattern with nested viewmodels. The master viewmodel is ShellView which contains three UserControls, each with their own viewmodel. The ShellView ViewModel is created in code-behind like so:</p>
  
  <pre><code>public ShellView()
  {
      InitializeComponent();
      _shellViewModel = new ShellViewModel();
      DataContext = _shellViewModel;
  }
  </code></pre>
  
  <p>Now, my ShellViewModel contains the other ViewModels as properties:</p>
  
  <pre><code>    public CustomerViewModel CustomerViewModel { get; set; }
  
      public ContactsViewModel ContactsViewModel { get; set; }
  </code></pre>
  
  <p>How do I access these properties from the XAML of the UserControls? I would like to be able to do something like:</p>
  
  <pre><code>DataContext="&lt;&lt;ParentWindowViewModel&gt;.CustomerViewModel&gt;
  </code></pre>
  
  <p>How can i accomplish this? I already tried:</p>
  
  <pre><code>DataContext="{Binding DataContext.CustomerViewModel, RelativeSource={RelativeSource FindAncestor, AncestorType=Window, AncestorLevel=1}, Path=DataContext.CustomerViewModel}"&gt;
  </code></pre>
  
  <p>but the debugger says "Cannot resolve property 'CustomerViewModel' in data context of type 'object'. Any help would be appreciated.</p>