title: Expand and Collapse a WPF Expander
body: <p>I have two Expanders in a DockPanel control, the first Expander that is at the top is set to isExpanded true while the other Expander is not. </p>
  
  <p>I just want the second Expander to go up whenever the first Expander is set to isExpanded false in run time...</p>
  
  <p>Here is my XAML code :</p>
  
  <pre><code>&lt;DockPanel LastChildFill="False" Margin="0,26,0,0" Background="#FF552D2D" HorizontalAlignment="Left" Width="149"&gt;
          &lt;StackPanel ScrollViewer.VerticalScrollBarVisibility="Auto"&gt;
              &lt;Expander x:Name="AdminManage" Header="Manage" Margin="0" Foreground="#FF14D0EE" Height="198" IsExpanded="True" Collapsed="AdminManage_Collapsed" Width="544"&gt;
                  &lt;StackPanel x:Name="AdminStackPanel" Height="177" Margin="0,0,-2,0"&gt;
                      &lt;Button Content="" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" Margin="23,0,0,0" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/&gt;
                      &lt;Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/&gt;
                      &lt;Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/&gt;
                      &lt;Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/&gt;
                      &lt;Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/&gt;
                      &lt;Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/&gt;
                      &lt;Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/&gt;
                      &lt;Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/Expander&gt;
              &lt;Expander Header="Account" Margin="0" VerticalAlignment="Top" Foreground="#FF14D0EE" Height="66"&gt;
                  &lt;StackPanel Height="44" Margin="0,0,-2,0"&gt;
                      &lt;Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/&gt;
                      &lt;Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/Expander&gt;
          &lt;/StackPanel&gt;
      &lt;/DockPanel&gt;
  </code></pre>