title: Setting DataContext on DataGrids
body: <p>I've developed an application with WPF and MVVM. In it I have a Window with a DataGrid. It's ViewModel contains some properties for the window and one property for the DataGrid (an <code>ObservableCollection&lt;DataGridItemViewModel&gt;</code>).</p>
  
  <p>In the window xaml I set the design DataContext in this way:</p>
  
  <pre><code>&lt;Window x:Class="XXX"
  
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  
              mc:Ignorable="d"
  
              d:DataContext="{d:DesignInstance TheTypeOfTheWindowViewModelHere}"&gt;
  </code></pre>
  
  <p>Then I want to set the design DataContext onto the DataGrid this way:</p>
  
  <pre><code>&lt;DataGrid ItemsSource="{Binding Path=PropertyOfTheDataGrid}" d:DataContext="{d:DesignInstance DataGridItemViewModel}" &gt;
  </code></pre>
  
  <p>But then I get a warning telling me that cannot find PropertyOfTheDataGrid inside DataGridItemViewModel. </p>
  
  <p>I thought I was setting only the DataContext of the ItemsSource but not I'm not sure if I'm doing it wrong or if its an issue of some kind.</p>
  
  <p>Thanks in advance.</p>