title: How can I programmatically access elements defined in a ContentTemplate?
body: <p>Let's say I've created a UserControl with the following ContentTemplate defined in XAML:</p>
  
  <pre><code>&lt;UserControl.ContentTemplate&gt;
      &lt;DataTemplate&gt; 
          &lt;Ellipse Name="myEllipse" Stroke="White"/&gt;
          &lt;ContentPresenter Content="{TemplateBinding Content}"/&gt;
      &lt;/DataTemplate&gt;
  &lt;/UserControl.ContentTemplate&gt;
  </code></pre>
  
  <p>How would I access the "myEllipse" element within my code so that, for example, I could find its height with "myEllipse.Height"?  I cannot access it by name directly.  I attempted to create a reference to it with:</p>
  
  <pre><code>Ellipse ellipse = ContentTemplate.FindName("myEllipse",this) as Ellipse;  
  </code></pre>
  
  <p>It crashes when I run the program, saying it can't create an instance of my class.  Perhaps I'm not using FindName correctly.  If anyone can help me out it would be much appreciated.</p>
  
  <p>Thanks,</p>
  
  <p>Dalal</p>