title: Access items inside the DataTemplate in WPF
body: <p>I was wondering if in WPF you are able to get the actual instances of the datatemplate objects. For example in the following situation:</p>
  
  <pre><code>&lt;UserControl&gt;
      &lt;UserControl.Resources&gt;
          &lt;DataTemplate x:Key="MyTemplate"&gt;
              &lt;CustomControl &gt;&lt;/CustomControl&gt;
          &lt;/DataTemplate&gt;
      &lt;/UserControl.Resources&gt;
  
      &lt;ListBox DataTemplate="{StaticResource MyTemplate}"&gt;&lt;/ListBox&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>Assume that <code>CustomControl</code> has a <code>CustomEvent</code> and a public <code>CustomMethod</code>. I want to access that event and the public method in the user control. Is this possible?  How would I be able to do this? Thanks in advance for any help.</p>
  
  <p>Cheers,</p>
  
  <p>Nilu</p>