<Window x:Class="KeyFrameAnimation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Key-Frame Animation" Height="200" Width="300">
<StackPanel Margin="15">
<TextBlock Name="label" Block.TextAlignment="Center" Foreground="Blue" />
<Rectangle Name="rect" Width="200" Height="100" Stroke="Blue" Margin="10">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Offset="0" />
<GradientStop Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<StackPanel.Triggers>
<EventTrigger RoutedEvent="StackPanel.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<StringAnimationUsingKeyFrames Storyboard.TargetName="label" Storyboard.TargetProperty="(TextBlock.Text)"
RepeatBehavior="Forever">
<DiscreteStringKeyFrame Value="Colormap: Spring" KeyTime="0:0:0" />
<DiscreteStringKeyFrame Value="Colormap: Summer" KeyTime="0:0:5" />
<DiscreteStringKeyFrame Value="Colormap: Autumn" KeyTime="0:0:10" />
<DiscreteStringKeyFrame Value="Colormap: Winter" KeyTime="0:0:15" />
<DiscreteStringKeyFrame Value="Colormap: Cool" KeyTime="0:0:20" />
<DiscreteStringKeyFrame Value="Colormap: Spring" KeyTime="0:0:25" />
</StringAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</StackPanel.Triggers>
</StackPanel>
</Window>
|