Use ColorAnimationUsingKeyFrames to animate the foreground color of a TextBlock : Frame Animation « Windows Presentation Foundation « C# / CSharp Tutorial






<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid TextBlock.FontSize="192">
        <TextBlock Name="txtblk" Foreground="Black"
                   HorizontalAlignment="Center" VerticalAlignment="Center" />
    </Grid> 
    <Page.Triggers>
        <EventTrigger RoutedEvent="Canvas.Loaded">
            <BeginStoryboard>
                <Storyboard TargetName="txtblk" Duration="0:0:2" RepeatBehavior="Forever">
                    <StringAnimationUsingKeyFrames Storyboard.TargetProperty="Text">
                        <DiscreteStringKeyFrame KeyTime="0:0:0" Value="textBoxA" />
                        <DiscreteStringKeyFrame KeyTime="0:0:1" Value="B" />
                    </StringAnimationUsingKeyFrames>

                    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.Color">
                        <DiscreteColorKeyFrame KeyTime="0:0:0" Value="Red" />
                        <DiscreteColorKeyFrame KeyTime="0:0:1" Value="Blue" />
                    </ColorAnimationUsingKeyFrames>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Page.Triggers>
</Page>
WPF Use Color Animation Using Key Frames To Animate The Foreground Color Of A Text Block








24.111.Frame Animation
24.111.1.Animation with Discrete Key FramesAnimation with Discrete Key Frames
24.111.2.Animation with Mixed Key Frames.xamlAnimation with Mixed Key Frames.xaml
24.111.3.Discrete Double Key FrameDiscrete Double Key Frame
24.111.4.Ball moves following spline key framesBall moves following spline key frames
24.111.5.Use ColorAnimationUsingKeyFrames to animate GradientStopUse ColorAnimationUsingKeyFrames to animate GradientStop
24.111.6.Use StringAnimationUsingKeyFrames to ColorUse StringAnimationUsingKeyFrames to Color
24.111.7.Using DiscreteStringKeyFrameUsing DiscreteStringKeyFrame
24.111.8.Use ColorAnimationUsingKeyFrames to animate the foreground color of a TextBlockUse ColorAnimationUsingKeyFrames to animate the foreground color of a TextBlock
24.111.9.Use StringAnimationUsingKeyFrames to animate the text value of a TextBlockUse StringAnimationUsingKeyFrames to animate the text value of a TextBlock