DiscretePointKeyFrame 类

定义

使用离散帧从上一个关键帧的 Point 值到其自己的 进行动画处理。

public ref class DiscretePointKeyFrame sealed : PointKeyFrame
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class DiscretePointKeyFrame final : PointKeyFrame
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class DiscretePointKeyFrame final : PointKeyFrame
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class DiscretePointKeyFrame : PointKeyFrame
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class DiscretePointKeyFrame : PointKeyFrame
Public NotInheritable Class DiscretePointKeyFrame
Inherits PointKeyFrame
<DiscretePointKeyFrame />
继承
Object Platform::Object IInspectable DependencyObject PointKeyFrame DiscretePointKeyFrame
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

此 XAML 示例沿三角形路径移动椭圆。 该示例使用 PointAnimationUsingKeyFrames 类对 EllipseGeometryCenter 属性进行动画处理。 此动画按以下方式使用三个关键帧:

  1. 在上半秒,它使用 LinearPointKeyFrame 类的实例沿路径以稳定速率从其起始位置移动椭圆。 线性关键帧(如 LinearPointKeyFrame )在值之间创建平滑的线性内插。
  2. 在下半秒结束时,它使用 DiscretePointKeyFrame 类的实例突然将椭圆沿路径移动到下一个位置。 离散关键帧(如 DiscretePointKeyFrame)会在值之间创建突然跳跃。
  3. 在最后两秒内,它使用 SplinePointKeyFrame 类的实例将椭圆移回其起始位置。 样条关键帧(如 SplinePointKeyFrame )根据 KeySpline 属性的值创建值之间的可变转换。 在此示例中,动画开始时较为缓慢,然后以指数方式加速,直到时间段结束。
<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

注解

关键帧动画允许沿动画时间线到达一个点的多个目标值。 换句话说,每个关键帧可以指定一个不同的中间值,并且到达的最后一个关键帧为最终动画值。 通过指定多个值来创建动画,你可以做出更复杂的动画。 可以在同一关键帧集合中混合离散、线性和样条关键帧。

有关如何使用关键帧动画的详细信息,请参阅 关键帧动画和缓动函数动画

构造函数

DiscretePointKeyFrame()

初始化 DiscretePointKeyFrame 类的新实例。

属性

Dispatcher

获取与此 对象关联的 CoreDispatcherCoreDispatcher 表示可以访问 UI 线程上的 DependencyObject 的工具,即使代码是由非 UI 线程启动的。

(继承自 DependencyObject)
KeyTime

获取或设置应达到关键帧的目标 的时间。

(继承自 PointKeyFrame)
Value

获取或设置关键帧的目标值。

(继承自 PointKeyFrame)

方法

ClearValue(DependencyProperty)

清除依赖属性的本地值。

(继承自 DependencyObject)
GetAnimationBaseValue(DependencyProperty)

返回为依赖属性建立的任何基值,该基值适用于动画未处于活动状态的情况。

(继承自 DependencyObject)
GetValue(DependencyProperty)

DependencyObject 返回依赖属性的当前有效值。

(继承自 DependencyObject)
ReadLocalValue(DependencyProperty)

如果设置了本地值,则返回依赖属性的本地值。

(继承自 DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

注册一个通知函数,用于侦听此 DependencyObject 实例上特定 DependencyProperty 的更改。

(继承自 DependencyObject)
SetValue(DependencyProperty, Object)

设置 DependencyObject 上依赖属性的本地值。

(继承自 DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

取消以前通过调用 RegisterPropertyChangedCallback 注册的更改通知。

(继承自 DependencyObject)

适用于

另请参阅