如何使用storyboard更改wpf中网格行的高度

时间:2010-01-07 00:43:10

标签: wpf binding grid row storyboard

我有Grid有2行:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="150"/>
        <RowDefinition />
        <RowDefinition Height="Auto" x:Name="OtherContactsRow" />
    </Grid.RowDefinitions>
    Something here
</Grid>

和2 Storyboard s:

<Storyboard x:Key="MaximizedStoryboard">
    <DoubleAnimation From="20" To="150"  Duration="0:0:2"
                     Storyboard.TargetName="OtherContactsRow"
                     Storyboard.TargetProperty="Height" >    
    </DoubleAnimation>
</Storyboard>

<Storyboard x:Key="MinimizedStoryboard">
    <DoubleAnimation From="150" To="20" Duration="0:0:2"
                     Storyboard.TargetName="OtherContactsRow"
                     Storyboard.TargetProperty="Height">
    </DoubleAnimation>
</Storyboard>

当我尝试修改名为OtherContactsRow的行的高度时,收到以下错误:

'System.Windows.Media.Animation.DoubleAnimation' animation object cannot be used to animate property 'Height' because it is of incompatible type 'System.Windows.GridLength'.

任何解决方案?

1 个答案:

答案 0 :(得分:-2)

您可以尝试ActualHeight属性。这是double