【问题标题】:how to change the height of a grid row in wpf using storyboard如何使用情节提要更改wpf中网格行的高度
【发布时间】:2011-01-02 07:29:53
【问题描述】:

我有一个有 2 行的 Grid

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

还有 2 个Storyboards:

<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'.

有什么解决办法吗?

【问题讨论】:

标签: wpf binding grid row storyboard


【解决方案1】:

你可以试试ActualHeight 属性。这是一个double

【讨论】:

  • 现在我收到此错误:'ActualHeight' Storyboard.TargetProperty 路径未指向 DependencyProperty。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-06-20
  • 2015-03-08
  • 2019-01-08
  • 2023-04-01
  • 2018-06-17
  • 2012-02-09
  • 2017-10-18
相关资源
最近更新 更多