故事板:EventTrigger 与 DataTrigger [英] Storyboard: EventTrigger vs DataTrigger

查看:38
本文介绍了故事板:EventTrigger 与 DataTrigger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

故事板概述:当属性值出现时动画Changes 提供了以下描述,试图解释EventTrigger 和 Storyboard"之间以及Trigger(即 DataTrigger)和 Storyboard"之间的关系,但对我来说听起来有点模棱两可,而且是一个简短的描述:

Storyboards Overview : Animate when a Property Value Changes provides the following description in a attempt to explain the relationship between "EventTrigger and Storyboard", and between "Trigger (i.e., DataTrigger) and Storyboard" but is sounds a bit ambiguous to me and somehow a short description:

由属性触发对象应用的动画在更多比 EventTrigger 动画或动画开始复杂的方式使用故事板方法.他们通过定义的动画切换"其他 Trigger 对象,但与 EventTrigger 和方法触发的动画.

Animations applied by property Trigger objects behave in a more complex fashion than EventTrigger animations or animations started using Storyboard methods. They "handoff" with animations defined by other Trigger objects, but compose with EventTrigger and method-triggered animations.

我知道 Storyboard 对象是只读的(可冻结),但我不明白的是在创建基于 EventTrigger 或基于触发器的 Storyboard 时发生的交互.术语切换"是否意味着共享故事板对象?有人可以详细说明上述报价说明的含义吗?

I do understand that Storyboard objects are read-only (freezable) but what i do not understand is the interaction that occurs when creating a Storyboard based on an EventTrigger or based on Triggers. Does the term "handoff" implies sharing of the storyboard object? can someone expand more on what is meant by above quote description?

这个问题是根据我对 在 DataTrigger 内绑定故事板动画会使 XamlParser 崩溃

This question was triggered based on my response to Binding a Storyboard Animation inside a DataTrigger crashes the XamlParser

推荐答案

当使用 EventTrigger 或 DataTrigger 创建 Storyboard 时,它会运行,但如果有多个值,那么每个触发器可能会有多个 Storyboard.因此,如果故事板正在为相同的属性设置动画,则必须先停止或删除第一个故事板,然后才能出现新的故事板动画.发生这种情况时,动画值返回到原始值,然后动画到新值.

When a Storyboard is created with an EventTrigger or DataTrigger it will run but if there are multiple values then there may be more than one storyboard for each trigger. So if the storyboards are animating the same properties then the first storyboard must be stopped or removed before the new storyboard animation can occur. When this happens the value that was animated returns to the original value and then animates to the new value.

如果我们使用基于多个触发器的 DataTrigger 或 EventTrigger 为对象的大小设置动画,那么您会注意到每个故事板在每个动画期间都从原始起点开始.所以你的动画从一点到下一点都不会流畅.这会导致 UI 体验分散注意力.

If we animate the size of an object with a DataTrigger or EventTrigger based on multiple triggers then you will notice that each storyboard starts at the original starting point during each animation. So your animations will not be smooth from one point to the next. This results in a distracting UI experience.

使用属性触发器,故事板将从上次停止的地方开始.基本上动画在从一种状态过渡到下一种状态时保持平滑,而不会在动画之前返回默认设置.

With property triggers the storyboards will pick up where the last left off. Basically the animation remains smooth in transition from one state to the next without a return to default before animating.

希望这会有所帮助.

这篇关于故事板:EventTrigger 与 DataTrigger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆