【问题标题】:C# WPF Designer Exception: animation object cannot be used to animate property 'Foreground' [duplicate]C# WPF 设计器异常:动画对象不能用于动画属性“前景”[重复]
【发布时间】:2013-06-09 08:47:55
【问题描述】:

以下代码在运行时运行良好,但设计器崩溃,我不知道为什么。

<VisualState x:Name="Selected" >
    <Storyboard>
        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="HeaderTopSelected">
            <EasingColorKeyFrame KeyTime="0" Value="White"/>
        </ColorAnimationUsingKeyFrames>
    </Storyboard>
</VisualState>

这会使设计器崩溃并出现以下错误:

'System.Windows.Media.Animation.ColorAnimationUsingKeyFrames' 动画对象不能用于动画属性“前景” 因为它是不兼容的类型'System.Windows.Media.Brush'

我已经尝试解决这个问题好几个小时了,我只是不知道为什么考虑到这个示例的设计师会在网上多次显示并在运行时工作。

谁能告诉我我做错了什么?

谢谢!

【问题讨论】:

  • 我在 2 年前辞掉了设计师的工作 :)

标签: c# wpf exception animation wpf-4.0


【解决方案1】:

您可能必须使用以下语法:

Storyboard.TargetProperty="(TextBlock.Foreground).Color"

“Foreground”和“SolidColorBrush”是同一个对象。

【讨论】:

  • 完美运行,非常感谢。
  • 特里,我不在乎社会是否还没有完全接受我现在对你的爱。我仍然会在屋顶上喊它。 +1。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-09
  • 1970-01-01
  • 2020-12-13
  • 1970-01-01
相关资源
最近更新 更多