title: In WPF, how do I bind in the DataGrid.RowDetailsTemplate?
body: <p>I have a DataGrid which is bound to an ObservableCollection of a custom class.  The  collection is a property in a ViewModel, and the grid works fine, including with changes to the collection.</p>
  
  <p>I want to use the RowDetailsTemplate to display two additional collections in a StackPannel, like so:</p>
  
  <pre><code>        &lt;DataGrid.RowDetailsTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel Name="GrcidSP" Orientation="Horizontal"&gt;
                      &lt;DataGrid Name="ClusterIndexGrid" AutoGenerateColumns="True" 
                                ItemsSource="{Binding ClusterIndexColumns}"
                                CanUserAddRows="False" CanUserResizeRows="False"
                                Width="Auto"/&gt;
                      &lt;DataGrid Name="IndexGrid" AutoGenerateColumns="True" 
                                ItemsSource="{Binding IndexColumns}"
                                CanUserAddRows="False" CanUserResizeRows="False"
                                Width="Auto"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/DataGrid.RowDetailsTemplate&gt;
  </code></pre>
  
  <p>ClusterIndexColumns and IndexColumns, the binding sources of the inner grids, are also collections in the ViewModel. </p>
  
  <p>Problem is, when i display the rowdetails, the datagrids are empty, i.e. not loaded at all, no columns or rows.</p>
  
  <p>In a bid to understand what is going on, i replaced the inner datagrids with label:</p>
  
  <pre><code>        &lt;DataGrid.RowDetailsTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel Name="GridSP" Orientation="Horizontal"&gt;
                      &lt;Label Content="{Binding}" Width="Auto" Background="AliceBlue"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/DataGrid.RowDetailsTemplate&gt;
  </code></pre>
  
  <p>and did not specify the binding source - {Binding}</p>
  
  <p>The label now displays the name of the custom class which is in the collection that is the source of the outer grid.</p>
  
  <p>So somehow, i need to navigate back to the ViewModel as the data context for the inner grids.</p>
  
  <p>But how, pray tell?</p>