DiscreteSizeKeyFrame Class
Collapse the table of content
Expand the table of content

DiscreteSizeKeyFrame Class

Animates from the Size value of the previous key frame to its own Value using discrete interpolation.

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 class DiscreteSizeKeyFrame : SizeKeyFrame
<DiscreteSizeKeyFrame .../>

This class is used as part of a SizeKeyFrameCollection in conjunction with a SizeAnimationUsingKeyFrames to animate a Size property value along a set of key frames.

A key frame defines a segment of the SizeAnimationUsingKeyFrames to which it belongs. Each key frame has a target Value and a KeyTime. The KeyTime specifies the time at which the key frame's Value should be reached. A key frame animates from the target value of the previous key frame to its own target value. It starts when the previous key frame ends and ends when its own key time is reached.

Discrete key frames like DiscreteSizeKeyFrame create sudden "jumps" between values (no Interpolation). In other words, the animated property does not change until the key frame's key time is reached at which point the animated property goes suddenly to the target value.

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5, 3.0

Community Additions

© 2015 Microsoft