Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-apply-animations-to-text.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

36 lines
2.6 KiB
Markdown

---
title: "How to: Apply Animations to Text"
ms.date: "03/30/2017"
helpviewer_keywords:
- "typography [WPF], animations"
- "animation [WPF], text"
ms.assetid: eec3d26c-0a21-420f-8012-671621c47089
---
# How to: Apply Animations to Text
Animations can alter the display and appearance of text in your application. The following examples use different types of animations to affect the display of text in a <xref:System.Windows.Controls.TextBlock> control.
## Example
The following example uses a <xref:System.Windows.Media.Animation.DoubleAnimation> to animate the width of the text block. The width value changes from the width of the text block to 0 over a duration of 10 seconds, and then reverses the width values and continues. This type of animation creates a wipe effect.
[!code-xaml[TextAnimationSample#TextAnimationSample1](~/samples/snippets/csharp/VS_Snippets_Wpf/TextAnimationSample/CS/Window1.xaml#textanimationsample1)]
The following example uses a <xref:System.Windows.Media.Animation.DoubleAnimation> to animate the opacity of the text block. The opacity value changes from 1.0 to 0 over a duration of 5 seconds, and then reverses the opacity values and continues.
[!code-xaml[TextAnimationSample#TextAnimationSample2](~/samples/snippets/csharp/VS_Snippets_Wpf/TextAnimationSample/CS/Window1.xaml#textanimationsample2)]
The following diagram shows the effect of the <xref:System.Windows.Controls.TextBlock> control changing its opacity from `1.00` to `0.00` during the 5-second interval defined by the <xref:System.Windows.Media.Animation.Timeline.Duration%2A>.
![Text changing opacity from 1.00 to 0.00.](./media/how-to-apply-animations-to-text/faded-text-opacity-change.png)
The following example uses a <xref:System.Windows.Media.Animation.ColorAnimation> to animate the foreground color of the text block. The foreground color value changes from one color to a second color over a duration of 5 seconds, and then reverses the color values and continues.
[!code-xaml[TextAnimationSample#TextAnimationSample3](~/samples/snippets/csharp/VS_Snippets_Wpf/TextAnimationSample/CS/Window1.xaml#textanimationsample3)]
The following example uses a <xref:System.Windows.Media.Animation.DoubleAnimation> to rotate the text block. The text block performs a full rotation over a duration of 20 seconds, and then continues to repeat the rotation.
[!code-xaml[TextAnimationSample#TextAnimationSample4](~/samples/snippets/csharp/VS_Snippets_Wpf/TextAnimationSample/CS/Window1.xaml#textanimationsample4)]
## See also
- [Animation Overview](../graphics-multimedia/animation-overview.md)