title: How to collapse all Group Expander in ListView?
body: <p>I have a <code>ListView</code> with a <code>GroupStyle</code> on it. And in the style i have an <code>Expander</code>. I want to use a <code>ContextMenu</code> in the <code>ListView</code> to collapse and expand all groups with one click and i want to expand every single group by clicking on the expander. How can i get the Groups and then expand this programmatically?</p>
  
  <pre><code>&lt;Style x:Key="PropertyGroupStyle" TargetType="{x:Type GroupItem}"&gt;
              &lt;Setter Property="Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate&gt;
                          &lt;Expander Header="{Binding Name}" IsExpanded="True"&gt;                               
                              &lt;ItemsPresenter /&gt;
                          &lt;/Expander&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;                    
              &lt;/Setter&gt;                
          &lt;/Style&gt;
  
  
  
  &lt;ListView Name="PropertyChangeList"
                                  IsSynchronizedWithCurrentItem="True" Height="Auto"                     
  
                                  ItemsSource="{Binding}"                 
                               &gt;
                                  &lt;ListView.GroupStyle&gt;
                                      &lt;GroupStyle ContainerStyle="{StaticResource PropertyGroupStyle}"/&gt;
                                  &lt;/ListView.GroupStyle&gt;
                                  &lt;ListView.ContextMenu&gt;
                                      &lt;ContextMenu&gt;
                                          &lt;MenuItem Name="menuItemPropertyExpanderCollapse"
                                              Header="{Binding Path=labelCollapse, FallbackValue='Collapse'}"
                                              Click="menuItemPropertyExpanderCollapse_Click" 
                                                    /&gt;
                                          &lt;MenuItem Name="menuItemPropertyExpanderExpand"
                                              Header="{Binding Path=labelExpand, FallbackValue='Expand'}"
  
                                    /&gt;
                                      &lt;/ContextMenu&gt;
                                  &lt;/ListView.ContextMenu&gt;
                                  &lt;ListView.View&gt;
                                      &lt;GridView AllowsColumnReorder="False" &gt;
                                          &lt;GridViewColumn Header="Date Occured"
                                                  Width="20"
                                                  DisplayMemberBinding="{Binding DateOccured}" /&gt;
  
                                          &lt;GridViewColumn Header="PropertyName"
                                                  Width="Auto"
                                                  DisplayMemberBinding="{Binding PropertyName}"/&gt;                                          
  
                                      &lt;/GridView&gt;
                                  &lt;/ListView.View&gt;
                              &lt;/ListView&gt;
  
  ICollectionView PropertyListview = CollectionViewSource.GetDefaultView(hPropList);
          PropertyListview.GroupDescriptions.Add(new PropertyGroupDescription("PropertyName"));
          PropertyListview.SortDescriptions.Add(new SortDescription("PropertyName", ListSortDirection.Ascending));
          PropertyListview.SortDescriptions.Add(new SortDescription("DateOccurred", ListSortDirection.Ascending));
  
          PropertyChangeList.ItemsSource = PropertyListview;
  </code></pre>
  
  <p>Has anybody an sample code to do the collapse and expand all groups with an <code>ContextMenu</code>? i dont find anything out there.</p>