Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-animate-the-thickness-of-a-border-by-using-key-frames.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

2.8 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Animate the Thickness of a Border by Using Key Frames 03/30/2017
animation [WPF], border thickness with key frames
key frames [WPF], animating border thickness with
border thickness [WPF], animating with key frames
3a9cb463-0a63-407d-aae7-3fbb1a559947

How to: Animate the Thickness of a Border by Using Key Frames

This example shows how to animate the xref:System.Windows.Controls.Control.BorderThickness%2A property of a xref:System.Windows.Controls.Border.

Example

The following example uses the xref:System.Windows.Media.Animation.ThicknessAnimationUsingKeyFrames class to animate the xref:System.Windows.Controls.Control.BorderThickness%2A property of a xref:System.Windows.Controls.Border. This animation uses three key frames in the following manner:

  1. During the first half second, uses an instance of the xref:System.Windows.Media.Animation.LinearThicknessKeyFrame class to gradually increase the thickness of the border. The example uses xref:System.Windows.Media.Animation.LinearThicknessKeyFrame to create a smooth linear increase between values.

  2. At the end of the next half second, uses an instance of the xref:System.Windows.Media.Animation.DiscreteThicknessKeyFrame class to suddenly increase the thickness of the border. Discrete key frames like those derived from xref:System.Windows.Media.Animation.DiscreteThicknessKeyFrame create sudden jumps between values, that is, the movement of the animation is jerky.

  3. During the final two seconds, uses an instance of the xref:System.Windows.Media.Animation.SplineThicknessKeyFrame class to decrease the thickness of the border. Spline key frames like those derived from xref:System.Windows.Media.Animation.SplineThicknessKeyFrame create a variable transition between values according to the values of the xref:System.Windows.Media.Animation.SplineThicknessKeyFrame.KeySpline%2A property. In this key frame, the animation starts off slow and speeds up exponentially toward the end of the time segment.

[!code-xamlkeyframes_snip#ThicknessAnimationUsingKeyFramesWholePage]

For the complete sample, see KeyFrame Animation Sample.

See also