title: How can I factor out a DataTemplate's binding in WPF?
body: <p>I have a <code>DataTemplate</code> I want to reuse. The part I want to factor out is the binding, because it's the only thing that changes. My <code>DataTemplate</code> looks roughly like this. (There's actually quite a bit more to it, but I've taken out the extraneous stuff.)</p>
  
  <pre><code>&lt;DataTemplate&gt;
      &lt;TextBox Text="{Binding Name}" /&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>How can I reuse this <code>DataTemplate</code> while simply varying the property to which I'm binding? (Note that if it were as simple as just a <code>TextBox</code>, I wouldn't worry about it, but the <code>DataTemplate</code> actually contains a <code>StackPane</code>l with a number of other elements in it. I want to centralize that in one place, hence the <code>DataTemplate</code>.)</p>
  
  <p>I've thought about two ways to tackle this problem.</p>
  
  <ol>
  <li>Create a simple custom control. Reuse that, and don't worry about reusing the <code>DataTemplate</code>.</li>
  <li>Experiment with some kind of subclass of DataTemplate. (I'm told this is possible.) I'd add a dependency property to it that lets me specify the name of the property to which I want to bind.</li>
  </ol>
  
  <p>Suggestions?</p>