title: WPF - ItemTemplate not acting as expected
body: <p>I have a <code>UserControl</code> which I'm using to display a list of <code>UIElement</code>s.  The control consists of a single <code>ItemsControl</code> with it's <code>ItemPanelTemplate</code> switched for a horizontal <code>StackPanel</code>, its <code>ItemsSource</code> bound to a <code>DependencyProperty</code> exposed by the <code>UserControl</code> and its <code>ItemTemplate</code> set in the <code>UserControl.Resources</code>.  </p>
  
  <p>Everything works fine except the <code>ItemTemplate</code> never get's applied and I can't see why.  The full source is below.</p>
  
  <p>UserControl.xaml - </p>
  
  <pre><code>&lt;UserControl x:Name="UC" x:FieldModifier="private" x:Class="ContentSliderControl.ContentSlider"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
  &lt;UserControl.Resources&gt;
  
      &lt;DataTemplate x:Key="pageTemplate"&gt;
          &lt;Border CornerRadius="10" Padding="5" Height="200" Width="200" Background="#333"&gt;
              &lt;ContentControl Content="{Binding}"/&gt;
          &lt;/Border&gt;
      &lt;/DataTemplate&gt;
  
      &lt;ItemsPanelTemplate x:Key="template"&gt;
          &lt;StackPanel IsItemsHost="True"
              Orientation="Horizontal"
              ScrollViewer.HorizontalScrollBarVisibility="Disabled"
              ScrollViewer.VerticalScrollBarVisibility="Disabled"/&gt;
      &lt;/ItemsPanelTemplate&gt;
  &lt;/UserControl.Resources&gt;
  
  &lt;ItemsControl ItemsPanel="{StaticResource template}" 
                ItemTemplate="{StaticResource pageTemplate}" 
                ItemsSource="{Binding ElementName=UC,Path=Pages}"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>UserControl.xaml.cs - </p>
  
  <pre><code>[ContentProperty("Pages")]
  public partial class ContentSlider : UserControl
  {
  
  
      public List&lt;UIElement&gt; Pages
      {
          get { return (List&lt;UIElement&gt;)GetValue(PagesProperty); }
          //set { SetValue(PagesProperty, value); }
      }
  
      // Using a DependencyProperty as the backing store for Pages.  This enables animation, styling, binding, etc...
      public static readonly DependencyProperty PagesProperty =
          DependencyProperty.Register("Pages", typeof(List&lt;UIElement&gt;), typeof(ContentSlider), new UIPropertyMetadata(null));
  
  
  
      public ContentSlider()
      {
          InitializeComponent();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I consume the control in my main window like this - </p>
  
  <pre><code>    &lt;slider:ContentSlider &gt;
      &lt;slider:ContentSlider.Pages&gt;
          &lt;Button&gt;1&lt;/Button&gt;
          &lt;Button&gt;2&lt;/Button&gt;
          &lt;Button&gt;3&lt;/Button&gt;
          &lt;Button&gt;4&lt;/Button&gt;
      &lt;/slider:ContentSlider.Pages&gt;
  &lt;/slider:ContentSlider&gt;
  </code></pre>
  
  <p>The buttons appear fine but not inside the 200px square border.</p>
  
  <p>Any help would be greatlly appriciated.
  Thanks.</p>