title: WPF HierarchicalDataTemplate & ItemsControl
body: <p>I have a list containing objects that follow this structure. This is not the real classes I am working with, but should explain the concept.</p>
  
  <p><strong>CLASSES</strong></p>
  
  <pre><code>public class BaseType{}
  public class TypeA : BaseType{}
  public class TypeB: BaseType
  {
      public List&lt;TypeA&gt; TypeAList { get; private set; }
  }
  </code></pre>
  
  <p>The List that the ItemsControl binds to is a <code>List&lt;BaseType&gt;</code></p>
  
  <p><strong>XAML</strong></p>
  
  <pre><code>&lt;ItemsControl&gt;
      &lt;ItemsControl.Resources&gt;
          &lt;HierarchicalDataTemplate DataType="{x:Type local:TypeB}" ItemsSource = "{Binding Path=TypeAList}"&gt;
              &lt;DataTemplate.Resources&gt;
                  &lt;Style TargetType="TextBlock"&gt;
                      &lt;Setter Property="FontSize" Value="18"/&gt;
                      &lt;Setter Property="HorizontalAlignment" Value="Center"/&gt;
                  &lt;/Style&gt;
              &lt;/DataTemplate.Resources&gt;
              &lt;Grid&gt;
                  &lt;Ellipse Fill="Gold"/&gt;
                  &lt;StackPanel&gt;
                      &lt;TextBlock Margin="3,3,3,0"
           Text="{Binding Path=Description}"/&gt;
                      &lt;TextBlock Margin="3,0,3,7"
           Text="{Binding Path=Name}"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/Grid&gt;
          &lt;/HierarchicalDataTemplate&gt;
      &lt;ItemsControl.Resources&gt;
      &lt;ItemsControl.ItemsPanel&gt;
          &lt;ItemsPanelTemplate&gt;
              &lt;StackPanel&gt;&lt;/StackPanel&gt;
          &lt;/ItemsPanelTemplate&gt;
      &lt;/ItemsControl.ItemsPanel&gt;
  &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>Now what I would expect to see is all the TypeA objects found in the TypeB object property to be displayed in the ItemsControl, instead I only see the TypeB objects, displayed with the styles defined for the HierarchicalDataTemplate. i've used the same datatemplate in a TreeView control, where it displays the child items fine.</p>
  
  <ul>
  <li>Can you not use a HierarchicalDataTemplate in an ItemsControl?</li>
  <li>How do you go about displaying a parent child relationship in an ItemsControl?</li>
  </ul>