title: ItemTemplate: ListBox vs ItemsControl
body: <p>I'm quite new to the WPF world and I'm having some problems with templating items in an <em>ItemsControl</em>. What I need is to template elements (mostly buttons) inside an <em>ItemsControl</em> (or the like). </p>
  
  <p>If I'm using the following XAML code ...</p>
  
  <pre><code>&lt;ItemsControl&gt;
      &lt;ItemsControl.ItemTemplate&gt;
          &lt;DataTemplate DataType="{x:Type Button}"&gt;
                  &lt;Border BorderBrush="AliceBlue" 
                          BorderThickness="3"&gt;
                      &lt;TextBlock Text="Templated!"/&gt;        
                  &lt;/Border&gt;
          &lt;/DataTemplate&gt;
      &lt;/ItemsControl.ItemTemplate&gt;
      &lt;Button&gt;Not templated&lt;/Button&gt;
      &lt;TextBlock&gt;Text not templated&lt;/TextBlock&gt;
  &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>... I get this result: <a href="http://img444.imageshack.us/img444/2167/itemscontrolnottemplate.gif" rel="noreferrer">http://img444.imageshack.us/img444/2167/itemscontrolnottemplate.gif</a></p>
  
  <p>The <em>ItemsControl</em> did not apply the template to either the <em>Button</em> nor to the <em>TextBlock</em> control. If I change the <em>ItemsControl</em> into a <em>ListBox</em> like this:</p>
  
  <pre><code>&lt;ListBox&gt;
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate DataType="{x:Type Button}"&gt;
                  &lt;Border BorderBrush="AliceBlue" 
                          BorderThickness="3"&gt;
                      &lt;TextBlock Text="Templated!"/&gt;        
                  &lt;/Border&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
      &lt;Button&gt;Not templated&lt;/Button&gt;
      &lt;TextBlock&gt;Text not templated&lt;/TextBlock&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>... then I'm getting this result: img814.imageshack.us/img814/6204/listboxtoomuchtemplatin.gif</p>
  
  <p>Now the template is applied to <strong>BOTH</strong> the child controls (even while I set the <em>DataType</em> to be <em>Button</em> only). </p>