为什么需要在括号中包围某些属性..ex:Storyboard.TargetProperty =“(背景)。(SolidColorBrush.Color)

时间:2012-09-10 19:27:22

标签: .net wpf xaml datatrigger coloranimation

标题几乎总结了它。我遇到了ColorAnimation无法正常工作的问题。我最终发现TargetProperty必须用括号括起来......虽然我不完全理解为什么?

有什么想法吗? (特别注意:Storyboard.TargetProperty =“)为什么它们必须在括号中?

<Style.Resources>
    <ColorAnimation x:Key="RecordingAnimation" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" From="White" To="Blue" Duration="0:0:0.5" AutoReverse="True" RepeatBehavior="Forever"/>
    <ColorAnimation x:Key="StopRecordingAnimation" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="White" Duration="0:0:0.1"/>
</Style.Resources>

2 个答案:

答案 0 :(得分:2)

引用

时需要使用括号
  • 多个对象和子属性,或
  • 附加财产名称

有关详细信息,请参阅Storyboard.TargetProperty

答案 1 :(得分:0)

像解析器一样想要解析你编写的代码。如果你想在目标对象中找到一个名为"Background.SolidColorBrush.Color"的属性并且知道哪个类型已经设置到属性中,显然你不能!因为目标对象中没有这样的属性。 “Background”部分引用属性名称,"SolidColorBrush"引用已设置到属性中的对象类型。它与Binding对象中的路径不同,您可以编写引用属性的完整路径。

我希望这会有所帮助。

干杯