【问题标题】:How to create Storyboard with Height TargetProperty如何使用 Height TargetProperty 创建情节提要
【发布时间】:2018-12-22 04:49:56
【问题描述】:

我想为Border HeightHeight 设置动画,方法是将其大小从0 调整为50

这是我尝试过的:

<Storyboard x:Key="showAnimation">
     <ThicknessAnimation Storyboard.TargetProperty="Height" 
                         From="0" To="50" 
                         DecelerationRatio=".9"
                         Duration="0:0:1" />
</Storyboard>

得到了这个错误:

System.InvalidOperationException: ''System.Windows.Media.Animation.ThicknessAnimation' 动画对象 不能用于动画属性“高度”,因为它是 不兼容的类型'System.Double'。'

【问题讨论】:

    标签: wpf xaml


    【解决方案1】:

    将 ThicknessAnimation 替换为 DoubleAnimation,因为 Height 是 Double,而不是 Thickness

    <Storyboard x:Key="showAnimation">
        <DoubleAnimation Storyboard.TargetProperty="Height" 
                         From="0" To="50" 
                         DecelerationRatio=".9" 
                         Duration="0:0:1" />
    </Storyboard>
    

    【讨论】:

      猜你喜欢
      • 2012-10-25
      • 2020-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多