[英]Animating background color of border in Silverlight, State precedence in VisualStateGroups
This is a silverlight/XAML question. 这是一个Silverlight / XAML问题。
Not sure what I'm doing wrong, this seems to throw an error: 不知道我在做什么错,这似乎引发了错误:
<ColorAnimation
Storyboard.TargetName="btnRemoveBorder"
Storyboard.TargetProperty="Background"
To="#FFDEBA29"
Duration="0" />
2nd question is... rather confused with the Selected and Focused states. 第二个问题是……与“选择状态”和“集中状态”相当混乱。 Can one state take precedence over another? 一个国家能否优先于另一个国家?
Background is not a Color but instead a Brush which is why it can't be animated directly with a ColorAnimation. 背景不是颜色,而是画笔,因此不能直接使用ColorAnimation对其进行动画处理。 Instead try the following. 而是尝试以下方法。
<ColorAnimation
Storyboard.TargetName="btnRemoveBorder"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="#FFDEBA29"
Duration="0" />
With regard to the VisualStateManager question, one state from each state group can be active. 关于VisualStateManager问题,每个状态组中的一个状态可以处于活动状态。 So in the case of a Button for example, it can be in both the Focused and Pressed state. 因此,例如对于Button,它可以同时处于Focused和Pressed状态。 For this reason, you should try to design your states and control templates in such a way that does not depend on which state becomes active first. 因此,您应该尝试设计状态和控制模板,而不依赖于哪个状态首先变为活动状态。 Usually this means you shouldn't animate the same element/property in two different state groups. 通常,这意味着您不应在两个不同的状态组中为相同的元素/属性设置动画。 But technically speaking, there's nothing preventing you from doing so. 但是从技术上讲,没有什么可以阻止您这样做。 Whichever state the control goes to last (using the VisualStateManager.GoToState method) will take precedence. 控件进入最后一个状态(使用VisualStateManager.GoToState方法)将优先。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.