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

发布于 2024-09-18 21:34:48 字数 276 浏览 2 评论 0原文

这是一个 silverlight/XAML 问题。

不确定我做错了什么,这似乎会引发错误:

<ColorAnimation 
Storyboard.TargetName="btnRemoveBorder" 
Storyboard.TargetProperty="Background" 
To="#FFDEBA29" 
Duration="0" />

第二个问题是......与“选定”和“聚焦”状态相当混淆。一个国家可以优先于另一个国家吗?

This is a silverlight/XAML question.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末染殇 2024-09-25 21:34:48

背景不是颜色而是画笔,这就是为什么它不能直接使用 ColorAnimation 进行动画处理。相反,请尝试以下操作。

<ColorAnimation 
    Storyboard.TargetName="btnRemoveBorder" 
    Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" 
    To="#FFDEBA29" 
    Duration="0" />

关于 VisualStateManager 问题,每个状态组中的一个状态可以是活动的。因此,以按钮为例,它可以同时处于“聚焦”和“按下”状态。因此,您应该尝试以不依赖于哪个状态首先变为活动状态的方式设计您的状态和控制模板。通常这意味着您不应该在两个不同的状态组中为相同的元素/属性设置动画。但从技术上讲,没有什么可以阻止你这样做。控件最后进入的状态(使用 VisualStateManager.GoToState 方法)将优先。

Background is not a Color but instead a Brush which is why it can't be animated directly with a 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. So in the case of a Button for example, it can be in both the Focused and Pressed state. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文