Search code examples
c#wpfxamlanimationstoryboard

Animate height of groupbox from 0 to auto


I have groupboxes acting like expanders in my application. When I need to colapse a groupbox I set its height equal to 0. when I need to expand it I set it's height equal to auto (double.Nan) is it posible to do this with a storyboard. How could I know the auto height in advance. Expression blend does not enable me to animate to an auto.

enter image description here


Solution

  • You can use ScaleTransform for this

    <GroupBox Header="GroupBox">
        <GroupBox.RenderTransform>
            <ScaleTransform ScaleY="1"/>
        </GroupBox.RenderTransform>
    </GroupBox>
    

    When collapse a groupbox set ScaleTransform.ScaleX to 0. And when expand set to 1.