Export (0) Print
Expand All

SizeAnimationUsingKeyFrames.KeyFrames Property

Gets or sets the collection of SizeKeyFrame objects that define the animation.

Namespace:  System.Windows.Media.Animation
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public SizeKeyFrameCollection KeyFrames { get; set; }
  <SizeKeyFrameCollection .../>

Property Value

Type: System.Windows.Media.Animation.SizeKeyFrameCollection
The collection of SizeKeyFrame objects that define the animation. The default value is Empty.

This example shows how to animate size changes by using key frames.

The following example uses the SizeAnimationUsingKeyFrames class to animate the Size property of an ArcSegment. This animation uses three key frames in the following manner:

  1. During the first half second of the animation, uses an instance of the LinearSizeKeyFrame class to gradually increase the size of the arc. Linear key frames like LinearSizeKeyFrame create a smooth linear transition between values.

  2. At the end of the next half second, uses an instance of the DiscreteSizeKeyFrame class to suddenly increase the size of the arc. Discrete key frames like DiscreteSizeKeyFrame create sudden jumps between values, that is, the size changes occur suddenly and are not subtle.

  3. Over the final two seconds, uses an instance of the SplineSizeKeyFrame class to increase the size of the arc. Spline key frames like SplineSizeKeyFrame create a variable transition between values according to the values of the KeySpline property. In this example, the size of the arc increases slowly at first and then increases exponentially toward the end of the time segment.

<!-- This example shows how to use the SizeAnimationUsingKeyFrames to animate the
size of an ArcSegment. -->
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

    <Canvas HorizontalAlignment="Left" Margin="0" >

      <!-- Create an arc on the screen that animates its size when it loads. -->
      <Path Stroke="Black" StrokeThickness="2" >
                <PathFigure StartPoint="100,200">
                      <ArcSegment x:Name="myArcSegment" Size="90,80" 
                      SweepDirection="Clockwise"  Point="500,200" />
          <EventTrigger RoutedEvent="Path.Loaded">
            <BeginStoryboard Name="myBeginStoryBoard">

                <!-- Animating the Size property uses 3 KeyFrames. -->
                Storyboard.TargetProperty="Size" >
                    <!-- Using a LinearSizeKeyFrame, the size of the arc increases
                         gradually over the first half second of the animation. -->
                    <LinearSizeKeyFrame KeyTime="0:0:0.5" Value="120,120" />

                    <!-- Using a DiscreteSizeKeyFrame, the size increases suddenly
                    after the first second of the animation. -->
                    <DiscreteSizeKeyFrame KeyTime="0:0:1" Value="150,150" />

                    <!-- Using a SplineSizeKeyFrame, the Size increases slowly at first 
                         and then speeds up exponentially. This KeyFrame takes 2 seconds. -->
                    <SplineSizeKeyFrame KeySpline="0.6,0.0 0.9,0.00" KeyTime="0:0:3" Value="300,300" />




For the complete sample, see KeyFrame Animation Sample.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2015 Microsoft