title: How do I bind datatemplate in a resource dictionary
body: <p>I'm trying to bind my elements in a datatemplate that is define in dictionary.
  Let's make it simple.</p>
  
  <p>I have a simple class</p>
  
  <pre><code>public class A { public string Data {get;set} }
  </code></pre>
  
  <p>I have a simple view that contains a ListBox, with ItemSources is a list of class A :</p>
  
  <pre><code>&lt;ListBox ItemsSource="{Binding AList}"&gt;
  </code></pre>
  
  <p>The point is, when I define Itemplate in view directly, bind works :</p>
  
  <pre><code>&lt;ListBox.ItemTemplate&gt;
     &lt;DataTemplate &gt;
        &lt;TextBlock Text="{Binding Data}" /&gt;
        &lt;Rectangle Fill="Red" Height="10" Width="10"/&gt;
     &lt;/DataTemplate&gt;
   &lt;/ListBox.ItemTemplate&gt;
  </code></pre>
  
  <p>This works great.</p>
  
  <p>But when I define this ItemTemplate in resource Dictionary, binding doesn't works ?</p>
  
  <p>How can I do that ?</p>
  
  <p>PS : This is a simple example to explain my problem, don't tell me to override toString function to make it works or use classe template, my real case is very more complexe than this.</p>
  
  <p>Thanks for help</p>