title: How to access the View inside the DataTemplate from Code behind
body: <p>I'm binding my viewmodel and view using resource dictionary as follows</p>
  
  <pre><code>&lt;DataTemplate DataType="{x:Type viewmodels:MyViewModel}"&gt;
      &lt;Views:MyView /&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>in MyView, i have dataGrid x:Name="BoxDataGrid" with DataGrid.RowDetailsTemplate having other dataGrid  x:Name="SpoolsDataGrid" </p>
  
  <p>how to access <strong><em>MyView</em></strong> or datagrids above using code behind in MyViewModel ?</p>
  
  <p>The reason is,i want to load and show contents inside RowDetailsTemplate only when main datagrid row selected (clicked) thru event "RowDetailsVisibilityChanged".</p>
  
  <p>Thanks.</p>
  
  <p>Correction:
   My bad. I want to access MyView not MyViewModel</p>