Storyboard: EventTrigger vs DataTrigger

2019-09-04 05:52发布

问题:

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:

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.

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?

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

回答1:

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.

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.

Hope this helps.