title: How to expand bound & styled TreeViewItem nodes
body: <p>I have a TreeView in WPF which I have bound to a collection of categories that itself contains a collection of categories and son on and so forth. Currently, I'm binding the collection successfully and having all of my category names appearing. However, I also have an IsExpanded property on my collection objects that when all set to true only expand the first TreeViewItem but no subsequent ones. </p>
  
  <p>Does anyone know what may be wrong with my TreeView styles?</p>
  
  <pre><code>&lt;HierarchicalDataTemplate x:Key="menuHierarchicalTemplate" ItemsSource="{Binding Path=SubCategories, Mode=TwoWay}" &gt;          
          &lt;Border x:Name="treeViewItemBorder"
                  CornerRadius="3"
                  MinWidth="125" 
                  BorderBrush="Silver" Background="Transparent"&gt;
                  &lt;StackPanel Orientation="Horizontal" &gt;
                      &lt;TextBlock Height="24" Padding="5" Text="{Binding Path=Name}" /&gt;
                  &lt;/StackPanel&gt;
              &lt;/Border&gt;
  &lt;/HierarchicalDataTemplate&gt;
  
  &lt;Style x:Key="treeViewItemStyle" TargetType="TreeViewItem"&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="TreeViewItem"&gt;
                      &lt;TreeViewItem IsExpanded="{Binding Path=IsExpanded, Mode=TwoWay}"
                                    ItemsSource="{Binding Path=SubCategories}"
                                    ItemTemplate="{StaticResource menuHierarchicalTemplate}" &gt;                              
                          &lt;TreeViewItem.Header&gt;                                
                              &lt;StackPanel Orientation="Horizontal" &gt;
                                  &lt;TextBlock Height="24" FontSize="12" Padding="5" Text="{Binding Path=Name}" /&gt;
                              &lt;/StackPanel&gt;                                
                          &lt;/TreeViewItem.Header&gt;                            
                      &lt;/TreeViewItem&gt;                        
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
  &lt;/Style&gt;
  
  &lt;TreeView Name="menuTreeView"
                  Background="Transparent"
                  BorderBrush="Transparent"
                  VerticalAlignment="Stretch"
                  HorizontalAlignment="Stretch"
                  Margin="10"   
                  ItemContainerStyle="{StaticResource treeViewItemStyle}"&gt;                
  &lt;/TreeView&gt;
  </code></pre>
  
  <p>Thanks,</p>
  
  <p>Xam</p>