如何在Code中编写这个XAML Storyboard?

时间:2015-04-20 08:01:17

标签: c# wpf

<Storyboard x:Key="CloseContentGrid">
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Height" Storyboard.TargetName="ContentGrid">
        <EasingDoubleKeyFrame KeyTime="0" Value="100"/>
        <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0"/>
    </DoubleAnimationUsingKeyFrames>
</Storyboard>

我想使用此动画将网格的HeightActualHeight(100)更改为Zero

1 个答案:

答案 0 :(得分:0)

你可以试试这个:

DoubleAnimation animation = new DoubleAnimation(100,0, new Duration(TimeSpan.FromMilliseconds(800)));
ContentGrid.BeginAnimation(HeightProperty, animation);