如何使用情节提要更改wpf中网格行的高度

Ali*_*lin 5 wpf grid binding row storyboard

我有Grid2 行:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="150"/>
        <RowDefinition />
        <RowDefinition Height="Auto" x:Name="OtherContactsRow" />
    </Grid.RowDefinitions>
    Something here
</Grid>
Run Code Online (Sandbox Code Playgroud)

和 2Storyboard秒:

<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>
Run Code Online (Sandbox Code Playgroud)

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

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

任何解决方案?

Jam*_*sey -3

你可以试试这个ActualHeight楼盘。它是一个double

  • 现在我收到此错误:“ActualHeight”Storyboard.TargetProperty 路径未指向 DependencyProperty。 (2认同)