tags:

views:

67

answers:

0

Tring to animate the expanding and contracting of a WPF Expander in .Net 4.0 using PowerEase. The animation works except I have to hardcode the height or bind to the height of an object in the expander which does not give the desired height. I need to set the "To" of the expander to Auto in animation.

 <Expander x:Name="MapsExpander" Background="DimGray" Header="MAPS" Foreground="WhiteSmoke" FontFamily="Arial" FontSize="12" IsExpanded="True" >
                <Expander.Resources>
                    <Storyboard x:Name="myStoryboardExpand" x:Key="myStoryboardExpand">
                        <DoubleAnimation From="{Binding ElementName=MapsExpander, Path=MinHeight}" To="{Binding Path=ActualHeight, ElementName=Text1, Mode=Default}" Duration="00:00:3" 
    Storyboard.TargetName="MapsExpander" 
    Storyboard.TargetProperty="Height">
                            <DoubleAnimation.EasingFunction>
                                <PowerEase Power="20" EasingMode="EaseOut"/>
                            </DoubleAnimation.EasingFunction>
                        </DoubleAnimation>
                    </Storyboard>

                    <Storyboard x:Name="myStoryboardContract" x:Key="myStoryboardContract">
                        <DoubleAnimation From="{Binding ElementName=MapsExpander, Path=ActualHeight}" To="30" Duration="00:00:3" 
    Storyboard.TargetName="MapsExpander" 
    Storyboard.TargetProperty="Height">
                            <DoubleAnimation.EasingFunction>
                                <PowerEase Power="20" EasingMode="EaseOut"/>
                            </DoubleAnimation.EasingFunction>
                        </DoubleAnimation>
                    </Storyboard>
                </Expander.Resources>

                <TextBlock x:Name="Text1" Text="Hi this is nothing but junk."/>
            </Expander>