我正在尝试使用 Expression blend 为对象的边框颜色设置动画。
每当我将 Storyboard 中的边框值更改为我之前创建的画笔资源的值时,对象的基本边框都会更改,而不是动画。如果我将属性的值更改为基值(即:我不使用画笔资源),动画将按预期工作。
我们不能使用画笔资源为颜色属性设置动画吗?
下面是 Expression Blend 在为边框使用硬编码颜色值时生成的代码(此代码有效,动画可以正常播放,但边框的值是硬编码的):
<Style x:Key="StandardTextBoxStyle" BasedOn="{x:Null}" TargetType="{x:Type TextBox}">
(...)
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid x:Name="grid">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
(...)
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0" To="Focused">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="rectangle">
<EasingColorKeyFrame KeyTime="0" Value="#FFC2C2C2"/>
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="#FF5FA5C9"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="Unfocused"/>
<VisualState x:Name="Focused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
(...)
</Style>
如何将硬编码值 #FF5FA5C9 替换为本地画笔资源的值?我应该用 DynamicResource / StaticResource 语句替换 Value="#FF5FA5C9" 语句吗?