This documentation is archived and is not being maintained.
ColorAnimationBase Class
Visual Studio 2008
Abstract class that, when implemented, animates a Color value.
Assembly: PresentationCore (in PresentationCore.dll)
Notes to Inheritors:
See the Custom Animations Overview for information about extending animation classes.
The following code example demonstrates how to use the derived ColorAnimationUsingKeyFrames class using Extensible Application Markup Language (XAML).
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="myRootElement" WindowTitle="ThicknessAnimationUsingKeyFrames Example"> <StackPanel Orientation="Vertical" HorizontalAlignment="Center"> <Border Background="#99FFFFFF" BorderThickness="28" Margin="0,60,0,20" Padding="20" > <Border.BorderBrush> <SolidColorBrush x:Name="MyAnimatedBrush" Color="Green" /> </Border.BorderBrush> <Border.Triggers> <EventTrigger RoutedEvent="Border.Loaded"> <BeginStoryboard> <Storyboard> <!-- Animate from green to red using a linear key frame, from red to yellow using a discrete key frame, and from yellow back to green with a spline key frame. This animation repeats forever. --> <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(SolidColorBrush.Color)" Storyboard.TargetName="MyAnimatedBrush" Duration="0:0:6" FillBehavior="HoldEnd" RepeatBehavior="Forever"> <ColorAnimationUsingKeyFrames.KeyFrames> <!-- Go from green to red in the first 2 seconds. LinearColorKeyFrame creates a smooth, linear animation between values. --> <LinearColorKeyFrame Value="Red" KeyTime="0:0:2" /> <!-- In the next half second, go to yellow. DiscreteColorKeyFrame creates a sudden jump between values. --> <DiscreteColorKeyFrame Value="Yellow" KeyTime="0:0: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="0:0:4.5" KeySpline="0.6,0.0 0.9,0.00" /> </ColorAnimationUsingKeyFrames.KeyFrames> </ColorAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </Border.Triggers> <TextBlock> This example shows how to use the ColorAnimationUsingKeyFrames to create an animation on the BorderBrush property of a Border. </TextBlock> </Border> </StackPanel> </Page>
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Freezable
System.Windows.Media.Animation.Animatable
System.Windows.Media.Animation.Timeline
System.Windows.Media.Animation.AnimationTimeline
System.Windows.Media.Animation.ColorAnimationBase
System.Windows.Media.Animation.ColorAnimation
System.Windows.Media.Animation.ColorAnimationUsingKeyFrames
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Freezable
System.Windows.Media.Animation.Animatable
System.Windows.Media.Animation.Timeline
System.Windows.Media.Animation.AnimationTimeline
System.Windows.Media.Animation.ColorAnimationBase
System.Windows.Media.Animation.ColorAnimation
System.Windows.Media.Animation.ColorAnimationUsingKeyFrames
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: