ColorAnimationUsingKeyFrames class

Applies to Windows and Windows Phone

Animates the value of a Color property along a set of key frames.

Inheritance

Object
  DependencyObject
    Timeline
      ColorAnimationUsingKeyFrames

Syntax


public sealed class ColorAnimationUsingKeyFrames : Timeline


<ColorAnimationUsingKeyFrames ...>
  oneOrMoreColorKeyFrames
</ColorAnimationUsingKeyFrames>

XAML Values

oneOrMoreColorKeyFrames

One or more object elements that define the key frames for the animation. These object elements represent one of the classes deriving from ColorKeyFrame. These are typically any combination of LinearColorKeyFrame, DiscreteColorKeyFrame, EasingColorKeyFrame, and SplineColorKeyFrame. Object elements defined here become members of the collection when code accesses the ColorAnimationUsingKeyFrames.KeyFrames property at run time.

Attributes

[ContentProperty("Name=KeyFrames")]
[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Members

The ColorAnimationUsingKeyFrames class has these types of members:

Constructors

The ColorAnimationUsingKeyFrames class has these constructors.

ConstructorDescription
ColorAnimationUsingKeyFrames Initializes a new instance of the ColorAnimationUsingKeyFrames class.

 

Events

The ColorAnimationUsingKeyFrames class has these events.

EventDescription
Completed Occurs when the Storyboard object has completed playing. (Inherited from Timeline)

 

Methods

The ColorAnimationUsingKeyFrames class has these methods. It also inherits methods from the Object class.

MethodDescription
ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject)
GetAnimationBaseValue Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject)
GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject)
ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject)
SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject)

 

Properties

The ColorAnimationUsingKeyFrames class has these properties.

PropertyAccess typeDescription

AutoReverse

Read/writeGets or sets a value that indicates whether the timeline plays in reverse after it completes a forward iteration. (Inherited from Timeline)

BeginTime

Read/writeGets or sets the time at which this Timeline should begin. (Inherited from Timeline)

Dispatcher

Read-onlyGets the CoreDispatcher that this object is associated with. (Inherited from DependencyObject)

Duration

Read/writeGets or sets the length of time for which this timeline plays, not counting repetitions. (Inherited from Timeline)

EnableDependentAnimation

Read/writeGets or sets a value that declares whether animated properties that are considered dependent animations should be permitted to use this animation declaration.

EnableDependentAnimationProperty

Read-onlyIdentifies the EnableDependentAnimation dependency property.

FillBehavior

Read/writeGets or sets a value that specifies how the animation behaves after it reaches the end of its active period. (Inherited from Timeline)

KeyFrames

Read-onlyGets the collection of ColorKeyFrame objects that define the animation.

RepeatBehavior

Read/writeGets or sets the repeating behavior of this timeline. (Inherited from Timeline)

SpeedRatio

Read/writeGets or sets the rate, relative to its parent, at which time progresses for this Timeline. (Inherited from Timeline)

 

Examples

The following 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 at all between values.

  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.


<StackPanel x:Name="myStackPanel" Background="Red"
Loaded="Start_Animation">
    <StackPanel.Resources>
        <Storyboard x:Name="colorStoryboard">

            <ColorAnimationUsingKeyFrames Storyboard.TargetName="myStackPanel" 
      Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                
                <!-- Go from green to red in the first 2 seconds. LinearColorKeyFrame creates
                a smooth, linear animation between values. -->
                <LinearColorKeyFrame Value="Blue" KeyTime="00:00:02" />

                <!-- In the next half second, go to yellow. DiscreteColorKeyFrame creates a 
                sudden jump between values. -->
                <DiscreteColorKeyFrame Value="Yellow" KeyTime="00:00:2.5" />

                <!-- In the final 2 seconds of the animation, go from yellow back to green. SplineColorKeyFrame 
                creates a variable transition between values depending on the KeySpline property. In this example,
                the animation starts off slow but toward the end of the time segment, it speeds up exponentially.-->
                <SplineColorKeyFrame Value="Green" KeyTime="00:00:4.5" KeySpline="0.6,0.0 0.9,0.00" />

            </ColorAnimationUsingKeyFrames>
        </Storyboard>
    </StackPanel.Resources>
</StackPanel>



// Start the animation when the object loads
private void Start_Animation(object sender, RoutedEventArgs e)
{
    colorStoryboard.Begin();
}


Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Media.Animation
Windows::UI::Xaml::Media::Animation [C++]

Metadata

Windows.winmd

See also

Storyboarded animations

 

 

Show:
© 2014 Microsoft