title: WPF - Create a UI object from a DataTemplate
body: <p>This is very similar to this <a href="https://stackoverflow.com/questions/2178387/get-the-ui-object-from-a-data-object">question</a> I asked earlier.  I am hoping to be clearer and get a different answser.</p>
  
  <p>I have a Data Object (called MockUI).  It has a data template (in app.xaml) like this:</p>
  
  <pre><code>&lt;DataTemplate DataType="{x:Type local:MockWI}"&gt;
      &lt;Button Content="{Binding Name}"/&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>In my code I want <strong>create</strong> a UI object that what the data template is.  So I have myMockWI and I want to find out what template that would use and get the object it creates (in this case a button with the content set to myMockWI).</p>
  
  <p>I have tried to just make a button:</p>
  
  <pre><code>Button myButton = new Button {Content = myMockWI}
  </code></pre>
  
  <p>but as you can probably guess, that creates the button then puts another button inside that button (because the data template is applied).  How can I get one button only?</p>