A Transition defines the animations to be applied when a State change occurs.

For example, the following Rectangle has two states: the default state, and an added “moved” state. In the “moved state, the rectangle’s position changes to (50, 50). The added Transition specifies that when the rectangle changes between the default and the “moved” state, any changes to the x and y properties should be animated, using an Easing.InOutQuad.

Notice the example does not require to and from values for the NumberAnimation. As a convenience, these properties are automatically set to the values of x and y before and after the state change; the from values are provided by the current values of x and y, and the to values are provided by the PropertyChanges object. If you wish, you can provide to and from values anyway to override the default values.

By default, a Transition’s animations are applied for any state change in the parent item. The Transition from and to values can be set to restrict the animations to only be applied when changing from one particular state to another.

If multiple Transitions are specified, only a single (best-matching) Transition will be applied for any particular state change. In the example above, when changing to state1, the first transition will be used, rather than the more generic second transition.

If a state change has a Transition that matches the same property as a Behavior, the Transition animation overrides the Behavior for that state change.

This property holds whether the Transition will be run when moving from the from state to the to state.

By default a Transition is enabled.

Note that in some circumstances disabling a Transition may cause an alternative Transition to be used in its place. In the following example, although the first Transition has been set to animate changes from “state1” to “state2”, this transition has been disabled by setting enabled to false, so any such state change will actually be animated by the second Transition instead.

This property holds whether the transition should be automatically reversed when the conditions that triggered this transition are reversed.

The default value is false.

By default, transitions run in parallel and are applied to all state changes if the from and to states have not been set. In this situation, the transition is automatically applied when a state change is reversed, and it is not necessary to set this property to reverse the transition.

However, if a SequentialAnimation is used, or if the from or to properties have been set, this property will need to be set to reverse a transition when a state change is reverted. For example, the following transition applies a sequential animation when the mouse is pressed, and reverses the sequence of the animation when the mouse is released: