title: parent container doesn't shrink when Expander is collapsed
body: <p>I have an Expander control inside of a Border control. When Expander is collapsed the Border retains of same height. How do I make the Border to change it's height also?
  The code that illustates the issue:</p>
  
  <pre><code>    &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition/&gt;
          &lt;RowDefinition/&gt;
          &lt;RowDefinition/&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Grid.Resources&gt;
          &lt;Style TargetType="Border"&gt;
              &lt;Setter Property="BorderBrush" Value="Red"/&gt;
              &lt;Setter Property="BorderThickness" Value="2" /&gt;
          &lt;/Style&gt;
          &lt;Style TargetType="StackPanel" x:Key="StackPanel1"&gt;
              &lt;Setter Property="Orientation" Value="Vertical"/&gt;
              &lt;Setter Property="MaxHeight" Value="100" /&gt;
          &lt;/Style&gt;
          &lt;LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="panelBackgroundBrush"&gt;
              &lt;LinearGradientBrush.GradientStops&gt;
                  &lt;GradientStop Color="#FFE3EFFF" Offset="0" /&gt;
                  &lt;GradientStop Color="#FFAFD2FF" Offset="1" /&gt;
              &lt;/LinearGradientBrush.GradientStops&gt;
          &lt;/LinearGradientBrush&gt;
          &lt;Style TargetType="{x:Type GridSplitter}"&gt;
              &lt;Setter Property="FrameworkElement.Height" Value="3"/&gt;
              &lt;Setter Property="UIElement.SnapsToDevicePixels" Value="True" /&gt;
              &lt;Setter Property="UIElement.Focusable" Value="False" /&gt;
              &lt;Setter Property="FrameworkElement.Cursor" Value="SizeNS"/&gt;
              &lt;Setter Property="VerticalAlignment" Value="Top"/&gt;
              &lt;Setter Property="HorizontalAlignment" Value="Stretch"/&gt;
              &lt;Setter Property="Control.Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate&gt;
                          &lt;Border&gt;
                              &lt;Border BorderThickness="0" BorderBrush="{StaticResource panelBackgroundBrush}"&gt;
                                  &lt;Canvas Width="19" Height="3"&gt;
                                      &lt;Canvas.Resources&gt;
                                          &lt;Style TargetType="Rectangle"&gt;
                                              &lt;Setter Property="Width" Value="2" /&gt;
                                              &lt;Setter Property="Height" Value="2" /&gt;
                                              &lt;Setter Property="Canvas.Top" Value="0" /&gt;
                                          &lt;/Style&gt;
                                      &lt;/Canvas.Resources&gt;
                                      &lt;Rectangle Fill="{StaticResource panelBackgroundBrush}" Canvas.Left="1" /&gt;
                                      &lt;Rectangle Fill="{StaticResource panelBackgroundBrush}" Canvas.Left="5" /&gt;
                                      &lt;Rectangle Fill="{StaticResource panelBackgroundBrush}" Canvas.Left="9" /&gt;
                                      &lt;Rectangle Fill="{StaticResource panelBackgroundBrush}" Canvas.Left="13" /&gt;
                                      &lt;Rectangle Fill="{StaticResource panelBackgroundBrush}" Canvas.Left="17" /&gt;
                                      &lt;Rectangle Fill="{TemplateBinding TextElement.Foreground}" Canvas.Left="0" /&gt;
                                      &lt;Rectangle Fill="{TemplateBinding TextElement.Foreground}" Canvas.Left="4" /&gt;
                                      &lt;Rectangle Fill="{TemplateBinding TextElement.Foreground}" Canvas.Left="8" /&gt;
                                      &lt;Rectangle Fill="{TemplateBinding TextElement.Foreground}" Canvas.Left="12" /&gt;
                                      &lt;Rectangle Fill="{TemplateBinding TextElement.Foreground}" Canvas.Left="16" /&gt;
                                  &lt;/Canvas&gt;
                              &lt;/Border&gt;
                          &lt;/Border&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
      &lt;/Grid.Resources&gt;
      &lt;Border&gt;
          &lt;Expander&gt;
              &lt;Border&gt;
                  &lt;StackPanel Style="{StaticResource ResourceKey=StackPanel1}" &gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/Border&gt;
          &lt;/Expander&gt;
      &lt;/Border&gt;
      &lt;Border Grid.Row="1"&gt;
          &lt;Expander&gt;
              &lt;Border&gt;
                  &lt;StackPanel Style="{StaticResource ResourceKey=StackPanel1}" &gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/Border&gt;
          &lt;/Expander&gt;
      &lt;/Border&gt;
      &lt;GridSplitter Grid.Row="1" /&gt;
      &lt;Border Grid.Row="2"&gt;
          &lt;Expander&gt;
              &lt;Border&gt;
                  &lt;StackPanel Style="{StaticResource ResourceKey=StackPanel1}" &gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                      &lt;TextBlock Text="aaaa"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/Border&gt;
          &lt;/Expander&gt;
      &lt;/Border&gt;
      &lt;GridSplitter Grid.Row="2" /&gt;
  &lt;/Grid&gt;
  </code></pre>