title: Collapse/Expand Groupboxes
body: <p>I have the following XAML, in which there are three group boxes stacked. In the header of those groupboxes are checkboxes.</p>
  
  <p>What I'd like to achieve : when I check/uncheck a box, I'd like the corresponding groupbox to slowly expand/collapse, with a smooth animation.</p>
  
  <p>I'm trying this in Blend 4 but am quite a newbie. Any help on how to achieve this ? In particular, can the animation be self-contained in the XAML ?</p>
  
  <p>UPDATE : <a href="https://stackoverflow.com/questions/6554437/animate-height-of-groupbox-from-0-to-auto">This seems to come close</a> , but I don't quite get it</p>
  
  <p><img src="https://i.stack.imgur.com/qINZK.png" alt="XAML Designer"></p>
  
  <pre><code>&lt;UserControl
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      x:Class="WpfControlLibrary1.MainControl"
      x:Name="MultiVol"&gt;
          &lt;StackPanel x:Name="LayoutRoot" HorizontalAlignment="Stretch"&gt;
              &lt;GroupBox Margin="8,0" BorderBrush="#FF88B1D8"&gt;
                  &lt;GroupBox.Header&gt;
                      &lt;WrapPanel&gt;
                      &lt;CheckBox IsChecked="True" VerticalAlignment="Center" /&gt;
                      &lt;Label Content="Volatility" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" FontFamily="/WpfControlLibrary1;component/Fonts/#Tahoma" /&gt; 
                      &lt;/WrapPanel&gt;
                  &lt;/GroupBox.Header&gt;
                  &lt;UniformGrid Columns="2"&gt;
                      &lt;Label Content="Spots"&gt;&lt;/Label&gt;
                      &lt;TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" /&gt;
                      &lt;Label Content="Hist. references" /&gt;
                      &lt;TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" /&gt;
                      &lt;Label Content="Tenors" /&gt;
                      &lt;TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" /&gt;
  
                  &lt;/UniformGrid&gt;
              &lt;/GroupBox&gt;
              &lt;GroupBox  Margin="8,0" BorderBrush="#FF88B1D8"&gt;
                  &lt;GroupBox.Header&gt;
                      &lt;WrapPanel&gt;
                      &lt;CheckBox IsChecked="True" VerticalAlignment="Center" /&gt;
                      &lt;Label Content="Skew" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" FontFamily="/WpfControlLibrary1;component/Fonts/#Tahoma" /&gt;   
                      &lt;/WrapPanel&gt;
                  &lt;/GroupBox.Header&gt;
                  &lt;UniformGrid Columns="2"&gt;
                      &lt;Label Content="Spot Intervals"&gt;&lt;/Label&gt;
                      &lt;TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" /&gt;
                      &lt;Label Content="Hist. references" /&gt;
                      &lt;TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" /&gt;
                      &lt;Label Content="Tenors" /&gt;
                      &lt;TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" /&gt;
                      &lt;Label Content="Compute 'Power'" /&gt;
                      &lt;CheckBox IsChecked="False" VerticalAlignment="Center"/&gt;
                  &lt;/UniformGrid&gt;
              &lt;/GroupBox&gt;
              &lt;GroupBox Margin="8,0" BorderBrush="#FF88B1D8"&gt;
                  &lt;GroupBox.Header&gt;
                      &lt;WrapPanel&gt;
                      &lt;CheckBox IsChecked="True" VerticalAlignment="Center" /&gt;
                      &lt;Label Content="Term structure" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" FontFamily="/WpfControlLibrary1;component/Fonts/#Tahoma" /&gt; 
                      &lt;/WrapPanel&gt;
                  &lt;/GroupBox.Header&gt;
                  &lt;UniformGrid Columns="2"&gt;
                      &lt;Label Content="Spots" /&gt;
                      &lt;TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" /&gt;
                      &lt;Label Content="Tenors" /&gt;
                      &lt;TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" /&gt;
                  &lt;/UniformGrid&gt;
              &lt;/GroupBox&gt; 
          &lt;/StackPanel&gt;
  &lt;/UserControl&gt;
  </code></pre>