4

我正在尝试为 Windows Phone 8 中列表框的选择更改设置动画。以下动画有效:

<ColorAnimation Storyboard.TargetProperty="(ContentControl.Foreground).(SolidColorBrush.Color)" Duration="00:00:00.25" From="{StaticResource PhoneForegroundColor}" To="{StaticResource PhoneAccentColor}" />

但是下一个不起作用(System.InvalidOperationException:无法在指定对象上解析 TargetProperty (ContentControl.Background).(SolidColorBrush.Color)。

<ColorAnimation Storyboard.TargetProperty="(ContentControl.Background).(SolidColorBrush.Color)" Duration="00:00:00.25" From="{StaticResource PhoneForegroundColor}" To="{StaticResource PhoneAccentColor}" />

对于我的生活,我无法找出原因。

4

1 回答 1

6

您需要将Background属性显式设置为您的某些东西ContentControl才能使动画正常工作。

您需要这个,因为该属性的默认值是当动画解析表达式时它无法访问.Backgroundnull(ContentControl.Background).(SolidColorBrush.Color)Colornull

它适用于, Foreground因为该属性的默认值Foreground是黑色画笔,因此默认情况下它被设置为有效的非空值。

于 2013-05-12T20:30:27.737 回答