Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 4.14 KB

linearcolorkeyframe.md

File metadata and controls

55 lines (36 loc) · 4.14 KB
-api-id -api-type
T:Windows.UI.Xaml.Media.Animation.LinearColorKeyFrame
winrt class

Windows.UI.Xaml.Media.Animation.LinearColorKeyFrame

-description

Animates from the Color value of the previous key frame to its own Value using linear interpolation.

-xaml-syntax

<LinearColorKeyFrame .../>

-remarks

Key-frame animations permit more than one target value that is reached at a point along the animation timeline. In other words each key frame can specify a different intermediate value, and the last key frame reached is the final animation value. By specifying multiple values to animate, you can make more complex animations. You'd typically have at least two keyframes in a ColorAnimationUsingKeyFrames with LinearColorKeyFrame, otherwise a ColorAnimation would have been simpler.

For more info on how to use key-frame animations, see Key-frame animations and easing function animations.

-examples

This XAML example uses the ColorAnimationUsingKeyFrames class to animate the Background property of a StackPanel. This animation uses three key frames in the following manner:

  1. During the first two seconds, LinearColorKeyFrame gradually changes the color from green to red. Linear key frames like LinearColorKeyFrame create a smooth linear transition between values.
  2. During the end of the next half second, DiscreteColorKeyFrame quickly changes the color from red to yellow. Discrete key frames like DiscreteColorKeyFrame create sudden changes between values; the animation occurs quickly and has no interpolation between values at all.
  3. During the final two seconds, SplineColorKeyFrame changes the color again, this time from yellow back to green. Spline key frames like SplineColorKeyFrame create a variable transition between values according to the values of the KeySpline property. A KeySpline provides a way to alter the relationship of time versus value during the animation duration to be nonlinear, and in particular the relationship can be a curve that would be difficult to produce with individual key frames. In this example, the change in color begins slowly and speeds up exponentially toward the end of the time segment.

[!code-xamlColoranimationusingkeyframes]

[!code-csharpColoranimationusingkeyframes_cs]

[!code-vbColoranimationusingkeyframes_cs]

-see-also

Storyboarded animations, Key-frame animations and easing function animations, ColorKeyFrame, ColorAnimationUsingKeyFrames, ColorKeyFrameCollection, KeyTime, Value, KeyTime, Value