title: TreeView child nodes expand but root node does not
body: <p>I have a strange WPF/XAML problem. By default, I want all of the nodes in this TreeView to be expanded. Eventually I'll bind it to my view model, but right now I just want them all expanded by default.</p>
  
  <p>This is the part of the code in question (that I am currently using)</p>
  
  <pre><code>&lt;HierarchicalDataTemplate DataType="{x:Type Model:DirectoryItem}"
                            ItemsSource="{Binding Items}"&gt;
      &lt;TextBlock Text="{Binding Path=Name}"
                 ToolTip="{Binding Path=Path}" /&gt;
      &lt;HierarchicalDataTemplate.ItemContainerStyle&gt;   
          &lt;Style TargetType="TreeViewItem"&gt;
              &lt;Setter Property="IsExpanded" Value="True" /&gt;
          &lt;/Style&gt; 
      &lt;/HierarchicalDataTemplate.ItemContainerStyle&gt;
  &lt;/HierarchicalDataTemplate&gt;
  
  &lt;DataTemplate DataType="{x:Type Model:FileItem}"&gt;
      &lt;TextBlock Text="{Binding Path=Name}"
                 ToolTip="{Binding Path=Path}" /&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>In particular, the part where I have the setter property as IsExpanded.</p>
  
  <p>As you can see by the images below, this code is sort-of working. If I expand the root nodes, then everything is expanded by default.</p>
  
  <p>But why are the root nodes not expanded by default as well? I have no idea why it is doing this.</p>
  
  <p><img src="https://i.stack.imgur.com/vb3mr.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/nVDLw.png" alt="enter image description here"></p>