Permalink
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (23 sloc) 2 KB
title ms.date helpviewer_keywords ms.assetid
How to: Animate a String by Using Key Frames
03/30/2017
animation [WPF], strings with key frames
strings [WPF], animating with key frames
key frames [WPF], animating strings with
c62bc9fd-c09a-4227-bce0-0a1ab82049dd

How to: Animate a String by Using Key Frames

This example shows how to animate a string, which in this example is the xref:System.Windows.Controls.ContentControl.Content%2A property of a xref:System.Windows.Controls.Button control, by using key frames.

Example

The following example uses the xref:System.Windows.Media.Animation.StringAnimationUsingKeyFrames class to animate the xref:System.Windows.Controls.ContentControl.Content%2A property of a xref:System.Windows.Controls.Button.

All the key frames in this example use an instance of the xref:System.Windows.Media.Animation.DiscreteStringKeyFrame class because a string animation that is created with key frames can only use discrete key frames. Discrete key frames like xref:System.Windows.Media.Animation.DiscreteStringKeyFrame create sudden jumps between values, that is, changes to the animation occur quickly and are not subtle.

[!code-xamlkeyframes_snip#StringAnimationUsingKeyFramesWholePage]

For the complete sample, see KeyFrame Animation Sample.

See Also

xref:System.Windows.Media.Animation.StringAnimationUsingKeyFrames
xref:System.Windows.Controls.ContentControl.Content%2A
xref:System.Windows.Controls.Button
xref:System.Windows.Media.Animation.DiscreteStringKeyFrame
Key-Frame Animations Overview
Key-Frame How-to Topics