简体   繁体   English

Silverlight中边框的动画背景色,VisualStateGroups中的状态优先级

[英]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.

相关问题 如何在Silverlight中在运行时基于文本块中的值更新边框的背景色? - How to update background color of the border based on value in textblock in runtime in Silverlight? 从互斥的VisualStateGroups中对相同属性进行动画处理 - Animating same property from mutually exclusive VisualStateGroups 边框上的Silverlight动态背景(使用渐变) - Silverlight Dynamic Background (using gradient) on Border 在Silverlight中更改MouseOver / MouseEnter上的HyperLinkBut​​ton的背景颜色 - Change background color of HyperLinkButton on MouseOver/MouseEnter in Silverlight 在Silverlight中更改Datagrid标头的背景颜色 - Change background color of Datagrid Header in Silverlight 在后面的代码中更改silverlight 5中按钮的背景颜色 - Change background color of button in silverlight 5 in code behind 如何在Silverlight中更改Combobox运行时的背景颜色? - how change background color of combobox runtime in silverlight? 如何在Silverlight中更改Textblock的背景颜色? - How to change the background color of a Textblock in Silverlight? 在Silverlight datagrid中设置DataGridHeaderBackground的背景颜色 - Set the background color of DataGridHeaderBackground in Silverlight datagrid 具有可设置背景色的Silverlight自定义形状区域 - Silverlight custom shape region with settable background color
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM