ColorAnimationUsingKeyFrames class
TOC
Collapse the table of content
Expand the table of content

ColorAnimationUsingKeyFrames class

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

Inheritance

Object
  DependencyObject
    Timeline
      ColorAnimationUsingKeyFrames

Syntax


Public NotInheritable Class ColorAnimationUsingKeyFrames
    Inherits 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.

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)
RegisterPropertyChangedCallback Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance. (Inherited from DependencyObject)
SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject)
UnregisterPropertyChangedCallback Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback. (Inherited from DependencyObject)

 

Properties

The ColorAnimationUsingKeyFrames class has these properties.

PropertyAccess typeDescription

AutoReverse

Read/write

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

BeginTime

Read/write

Gets or sets the time at which this Timeline should begin. (Inherited from Timeline)

Dispatcher

Read-only

Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread. (Inherited from DependencyObject)

Duration

Read/write

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

EnableDependentAnimation

Read/write

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

EnableDependentAnimationProperty

Read-only

Identifies the EnableDependentAnimation dependency property.

FillBehavior

Read/write

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

KeyFrames

Read-only

Gets the collection of ColorKeyFrame objects that define the animation.

RepeatBehavior

Read/write

Gets or sets the repeating behavior of this timeline. (Inherited from Timeline)

SpeedRatio

Read/write

Gets 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 Sub Start_Animation(ByVal sender As Object, ByVal e As EventArgs)
    colorStoryboard.Begin()
End Sub


Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

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

Attributes

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

See also

Object
Storyboarded animations

 

 

Show:
© 2016 Microsoft