PointAnimationUsingKeyFrames PointAnimationUsingKeyFrames PointAnimationUsingKeyFrames Class

Animates the value of a Point property along a set of KeyFrames.

Syntax

Declaration

public sealed class PointAnimationUsingKeyFramespublic sealed class PointAnimationUsingKeyFramesPublic NotInheritable Class PointAnimationUsingKeyFrames
<PointAnimationUsingKeyFrames>
  oneOrMorePointKeyFrames
</PointAnimationUsingKeyFrames>

Inheritance Hierarchy

Inherited Members

Inherited properties

, , , , , , , , , , , , ,

Inherited methods

, , , , , ,

Inherited events

Remarks

Examples

The following example moves an ellipse along a triangular path. The example uses the PointAnimationUsingKeyFrames class to animate the Center property of an EllipseGeometry. This animation uses three key frames in the following manner:

  1. During the first half second, it uses an instance of the LinearPointKeyFrame class to move the ellipse along a path at a steady rate from its starting position. Linear key frames such as LinearPointKeyFrame create a smooth linear interpolation between values.
  2. During the end of the next half second, it uses an instance of the DiscretePointKeyFrame class to suddenly move the ellipse along the path to the next position. Discrete key frames like DiscretePointKeyFrame create sudden jumps between values.
  3. During the final two seconds, it uses an instance of the SplinePointKeyFrame class to move the ellipse back to its starting position. Spline key frames like SplinePointKeyFrame create a variable transition between values according to the values of the KeySpline property. In this example, the animation begins slowly and speeds up exponentially toward the end of the time segment.
<Canvas Width="400" Height="300">
    <Canvas.Resources>
        <Storyboard x:Name="myStoryboard">

            <!-- Animating the Center property uses 3 KeyFrames, which animate
             the ellipse allong a triangular path. -->
            <PointAnimationUsingKeyFrames
          Storyboard.TargetProperty="Center"
          Storyboard.TargetName="MyAnimatedEllipseGeometry"
          Duration="0:0:5" RepeatBehavior="Forever" EnableDependentAnimation="True">

                <!-- Over the first half second, Using a LinearPointKeyFrame, the ellipse 
               moves steadily from its starting position along the first line of the 
               trianglar path.  -->
                <LinearPointKeyFrame KeyTime="0:0:0.5" Value="100,300" />

                <!-- Using a DiscretePointKeyFrame, the ellipse suddenly changes position
               after the first second of the animation. -->
                <DiscretePointKeyFrame KeyTime="0:0:1" Value="400,300" />

                <!-- Using a SplinePointKeyFrame, the ellipse moves back to its starting
               position. It moves slowly at first and then speeds up. This key frame 
               takes 2 seconds to complete. -->
                <SplinePointKeyFrame KeySpline="0.6,0.0 0.9,0.00" 
                 KeyTime="0:0:3" Value="200,100" />
            </PointAnimationUsingKeyFrames>
        </Storyboard>
    </Canvas.Resources>
    <Path Fill="Blue" Loaded="Start_Animation">
        <Path.Data>

            <!-- Describes an ellipse. -->
            <EllipseGeometry x:Name="MyAnimatedEllipseGeometry"
             Center="200,100" RadiusX="15" RadiusY="15" />
        </Path.Data>
    </Path>
</Canvas>
// Start the animation when the object loads
private void Start_Animation(object sender, RoutedEventArgs e)
{
    myStoryboard.Begin();
}
' Start the animation when the object loads
Private Sub Start_Animation(ByVal sender As Object, ByVal e As EventArgs)
    myStoryboard.Begin()
End Sub

Constructors summary

Initializes a new instance of the PointAnimationUsingKeyFrames class.

Properties summary

Gets or sets a value that declares whether animated properties that are considered dependent animations should be permitted to use this animation declaration.

Identifies the EnableDependentAnimation dependency property.

Gets the collection of PointKeyFrame objects that define the animation.

Constructors

  • PointAnimationUsingKeyFrames()
    PointAnimationUsingKeyFrames()
    PointAnimationUsingKeyFrames()
    PointAnimationUsingKeyFrames()

    Initializes a new instance of the PointAnimationUsingKeyFrames class.

    public PointAnimationUsingKeyFrames()public New()Public Sub New()public PointAnimationUsingKeyFrames()

Properties

  • EnableDependentAnimation
    EnableDependentAnimation
    EnableDependentAnimation
    EnableDependentAnimation

    Gets or sets a value that declares whether animated properties that are considered dependent animations should be permitted to use this animation declaration.

    public bool EnableDependentAnimation { get; set; }public bool EnableDependentAnimation { get; set; }Public ReadWrite Property EnableDependentAnimation As boolpublic bool EnableDependentAnimation { get; set; }
    <PointAnimationUsingKeyFrames EnableDependentAnimation="bool" />
    

    Property Value

    • bool
      bool
      bool

      true if the animation can be used for a dependent animation case. false if the animation cannot be used for a dependent animation case. The default is false.

    Remarks

    What's considered a dependent animation?

    Not all custom animations you create can run by default in a Windows Runtime app, if the animation system determines that the animation might cause bad performance in your UI. Animations where the system determines there could be a performance impact are called dependent animations. It's dependent because your animation is actively and frequently updating objects on the UI thread, which is also where current user input and other programmatic updates are making runtime changes to UI.

    A dependent animation that's consuming extensive system resources on the UI thread can make the app appear unresponsive in certain situations. If your animation causes a layout change or otherwise has the potential to impact performance on the UI thread, you often need to explicitly enable the animation to see it run. That's what the EnableDependentAnimation property on specific animation classes is for. Use this property with caution, because setting it to true means you are deliberately acknowledging that the animation might slow down other operations on the UI thread when it runs.

    For more info, see Storyboarded animations. That topic includes a list of the criteria for an independent animation. An animation is a dependent animation if it doesn't satisfy at least one of those criteria. For the specific property you intend to animate, and for the specifics of your animation, compare your intended animation to the criteria to see whether it would be considered dependent or independent by the system.

    Another way to discover whether your animations are dependent is that you might receive a warning from your XAML design surface or tool after you compose that animation, and the warning indicates that you'll need to set EnableDependentAnimation to true to see your animation run.

    As an app developer, you can also choose to apply an app-wide setting that always disables dependent animations, even those where EnableDependentAnimation is true. See AllowDependentAnimations. This is useful to you as an app developer if you're consuming controls where the templates have dependent animations, and you've identified that as a performance problem, but you don't want to have to retemplate the whole control to turn those animations off.

  • EnableDependentAnimationProperty
    EnableDependentAnimationProperty
    EnableDependentAnimationProperty
    EnableDependentAnimationProperty

    Identifies the EnableDependentAnimation dependency property.

    public static DependencyProperty EnableDependentAnimationProperty { get; }public static DependencyProperty EnableDependentAnimationProperty { get; }Public Static ReadOnly Property EnableDependentAnimationProperty As DependencyPropertypublic static DependencyProperty EnableDependentAnimationProperty { get; }

    Property Value

  • KeyFrames
    KeyFrames
    KeyFrames
    KeyFrames

    Gets the collection of PointKeyFrame objects that define the animation.

    public PointKeyFrameCollection KeyFrames { get; }public PointKeyFrameCollection KeyFrames { get; }Public ReadOnly Property KeyFrames As PointKeyFrameCollectionpublic PointKeyFrameCollection KeyFrames { get; }
    <PointAnimationUsingKeyFrames>
      oneOrMorePointKeyFrames
    </PointAnimationUsingKeyFrames>
    

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute
Windows.UI.Xaml.Markup.ContentPropertyAttribute

Details

Assembly

Windows.UI.Xaml.Media.Animation.dll