title: WPF TreeView HierarchicalDataTemplate get TreeViewItem
body: <p>I am using a HierarchicalDataTemplate to bind my classes to a TreeView with checkboxes.  I have the code working fine and everything is displayed fine, but I'd like to be able to get a list of children of an item in my treeview.</p>
  
  <p>When a checkbox is clicked, I want to be able to select the parent nodes and child nodes.  If I had access to the TreeViewItem that is supposed to wrap the checkbox then I could easily do this, but the Parent property of the Checkbox is null... I can only seem to gain access to my classes that are mapped in the HierarchicalDataTemplate.</p>
  
  <pre><code>&lt;TreeView Margin="12" Name="trv1" SelectedItemChanged="trv1_SelectedItemChanged"&gt;
          &lt;TreeView.Resources&gt;
              &lt;HierarchicalDataTemplate DataType="{x:Type src:Location}" ItemsSource="{Binding Path=Sublocations}"&gt;
                  &lt;CheckBox Content="{Binding Name}" Tag="{Binding}" IsChecked="{Binding IsChecked}" Click="checkBox_Click"/&gt;
              &lt;/HierarchicalDataTemplate&gt;
  
              &lt;HierarchicalDataTemplate DataType="{x:Type src:Sublocation}" ItemsSource="{Binding Path=Children}"&gt;
                  &lt;CheckBox Content="{Binding Name}" Tag="{Binding}" IsChecked="{Binding IsChecked}" Click="checkBox_Click"/&gt;
              &lt;/HierarchicalDataTemplate&gt;
  
              &lt;DataTemplate DataType="{x:Type src:Child}"&gt;
                  &lt;CheckBox Content="{Binding Name}" Tag="{Binding}" IsChecked="{Binding IsChecked}" Click="checkBox_Click"/&gt;
              &lt;/DataTemplate&gt;
  
          &lt;/TreeView.Resources&gt;
      &lt;TreeView.ItemContainerStyle&gt;
          &lt;Style TargetType="TreeViewItem"&gt;
              &lt;Setter Property="IsSelected" Value="{Binding IsChecked}"/&gt;
          &lt;/Style&gt;
      &lt;/TreeView.ItemContainerStyle&gt;
  &lt;/TreeView&gt;
  </code></pre>