Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ThicknessAnimationUsingKeyFrames.KeyFrames Property

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

Namespace: System.Windows.Media.Animation
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public ThicknessKeyFrameCollection KeyFrames { get; set; }
/** @property */
public ThicknessKeyFrameCollection get_KeyFrames ()

/** @property */
public void set_KeyFrames (ThicknessKeyFrameCollection value)

public function get KeyFrames () : ThicknessKeyFrameCollection

public function set KeyFrames (value : ThicknessKeyFrameCollection)

<object>
  <ThicknessKeyFrameCollection .../>
</object>

Property Value

The collection of ThicknessKeyFrame objects that define the animation. The default value is Empty.

This example shows how to animate the BorderThickness property of a Border.

The following example uses the ThicknessAnimationUsingKeyFrames class to animate the BorderThickness property of a Border. This animation uses three key frames in the following manner:

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

  2. At the end of the next half second, uses an instance of the DiscreteThicknessKeyFrame class to suddenly increase the thickness of the border. Discrete key frames like those derived from 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 SplineThicknessKeyFrame class to decrease the thickness of the border. Spline key frames like those derived from SplineThicknessKeyFrame create a variable transition between values according to the values of the KeySpline property. In this key frame, the animation starts off slow and speeds up exponentially toward the end of the time segment.

<!-- This example shows how to use the ThicknessAnimationUsingKeyFrames to create
an animation on the BorderThickness property of a Border. -->
<Page  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="Microsoft.Samples.KeyFrameExamples.ThicknessAnimationUsingKeyFramesExample"
  Name="myRootElement"
  WindowTitle="ThicknessAnimationUsingKeyFrames Example">

  <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
    <Border Background="#99FFFFFF" BorderBrush="#CCCCFF" BorderThickness="1"
    Margin="0,60,0,20" Padding="20"  >
      <Border.Triggers>
        <EventTrigger RoutedEvent="Border.Loaded">
          <BeginStoryboard>
            <Storyboard>

              <!-- Animating the BorderThickness property uses 3 KeyFrames. -->
              <ThicknessAnimationUsingKeyFrames
                Storyboard.TargetProperty="BorderThickness"
                Duration="0:0:5" FillBehavior="HoldEnd" RepeatBehavior="Forever">
                <ThicknessAnimationUsingKeyFrames.KeyFrames>

                  <!-- Using a LinearThicknessKeyFrame, thickness increases gradually
                  over the first half second of the animation. -->
                  <LinearThicknessKeyFrame KeyTime="0:0:0.5">
                    <LinearThicknessKeyFrame.Value>
                      <Thickness Left="8" Right="8" Top="6" Bottom="6" />
                    </LinearThicknessKeyFrame.Value>
                  </LinearThicknessKeyFrame>

                  <!-- Using a DiscreteThicknessKeyFrame, thickness increases suddenly
                  after the first second of the animation. -->
                  <DiscreteThicknessKeyFrame KeyTime="0:0:1">
                    <DiscreteThicknessKeyFrame.Value>
                      <Thickness Left="28" Right="28" Top="24" Bottom="24" />
                    </DiscreteThicknessKeyFrame.Value>
                  </DiscreteThicknessKeyFrame>

                  <!-- Using a SplineThicknessKeyFrame, thickness decreases slowly at first
                  and then suddenly contracts. This KeyFrame takes 2 seconds. -->
                  <SplineThicknessKeyFrame KeySpline="0.6,0.0 0.9,0.00" KeyTime="0:0:3">
                    <SplineThicknessKeyFrame.Value>
                      <Thickness Left="1" Right="1" Top="1" Bottom="8" />
                    </SplineThicknessKeyFrame.Value>
                  </SplineThicknessKeyFrame>

                </ThicknessAnimationUsingKeyFrames.KeyFrames>
              </ThicknessAnimationUsingKeyFrames>
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Border.Triggers>

      <TextBlock>
        This example shows how to use the ThicknessAnimationUsingKeyFrames to create
        an animation on the BorderThickness property of a Border. 
      </TextBlock>
    </Border>

  </StackPanel>
</Page>

For the complete sample, see KeyFrame Animation Sample.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.