LinearDoubleKeyFrame 类

定义

使用线性内插从上一个关键帧的 Double 值到其自己的 进行动画处理。

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

示例

此 XAML 示例在屏幕上移动一个矩形。 该示例使用 LinearDoubleKeyFrame 类对应用于 RectangleTranslateTransformX 属性进行动画处理。 此动画按以下方式使用三个关键帧:

  1. 在前三秒,它使用 LinearDoubleKeyFrame 类的实例沿路径以稳定速率将矩形从起始位置移动到 500 位置。 线性关键帧(如 LinearDoubleKeyFrame)在值之间创建平滑的线性转换。
  2. 在第四秒结束时,它使用 DiscreteDoubleKeyFrame 类的实例将矩形突然移动到下一个位置。 离散关键帧(如 DiscreteDoubleKeyFrame) 会在值之间创建突然跳转。 在该示例中,矩形位于起始位置,然后突然出现在 500 位置。
  3. 在最后两秒内,它使用 SplineDoubleKeyFrame 类的实例将矩形移回其起始位置。 SplineDoubleKeyFrame 等样条关键帧根据 KeySpline 属性的值在值之间创建可变转换。 在本示例中,矩形开始时缓慢移动,然后以指数级加速,直到时间段结束。
<StackPanel>
    <StackPanel.Resources>
        <Storyboard x:Name="myStoryboard">

            <!-- Animate the TranslateTransform's X property
             from 0 to 350, then 50,
             then 200 over 10 seconds. -->
            <DoubleAnimationUsingKeyFrames
          Storyboard.TargetName="MyAnimatedTranslateTransform"
          Storyboard.TargetProperty="X"
          Duration="0:0:10" EnableDependentAnimation="True">

                <!-- Using a LinearDoubleKeyFrame, the rectangle moves 
                 steadily from its starting position to 500 over 
                 the first 3 seconds.  -->
                <LinearDoubleKeyFrame Value="500" KeyTime="0:0:3" />

                <!-- Using a DiscreteDoubleKeyFrame, the rectangle suddenly 
                 appears at 400 after the fourth second of the animation. -->
                <DiscreteDoubleKeyFrame Value="400" KeyTime="0:0:4" />

                <!-- Using a SplineDoubleKeyFrame, the rectangle moves 
                 back to its starting point. The
                 animation starts out slowly at first and then speeds up. 
                 This KeyFrame ends after the 6th
                 second. -->
                <SplineDoubleKeyFrame KeySpline="0.6,0.0 0.9,0.00" Value="0" KeyTime="0:0:6" />

            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </StackPanel.Resources>
    <Rectangle Fill="Blue" Width="50" Height="50" Loaded="Start_Animation">
        <Rectangle.RenderTransform>
            <TranslateTransform x:Name="MyAnimatedTranslateTransform" 
             X="0" Y="0" />
        </Rectangle.RenderTransform>
    </Rectangle>
</StackPanel>
// Start the animation when the object loads
private void Start_Animation(object sender, RoutedEventArgs e)
{
    myStoryboard.Begin();
}

注解

关键帧动画允许沿动画时间线到达一个点的多个目标值。 换句话说,每个关键帧可以指定一个不同的中间值,并且到达的最后一个关键帧为最终动画值。 通过指定多个值来创建动画,你可以做出更复杂的动画。 在 DoubleAnimationUsingKeyFrames 和 LinearDoubleKeyFrame 中,通常至少有两个关键帧,否则 DoubleAnimation 会更简单。

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

构造函数

LinearDoubleKeyFrame()

初始化 LinearDoubleKeyFrame 类的新实例。

属性

Dispatcher

始终在Windows 应用 SDK应用中返回 null 。 请改用 DispatcherQueue

(继承自 DependencyObject)
DispatcherQueue

DispatcherQueue获取与此对象关联的 。 表示 DispatcherQueue 一个可以在 UI 线程上访问 DependencyObject 的设施,即使代码是由非 UI 线程启动的。

(继承自 DependencyObject)
KeyTime

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

(继承自 DoubleKeyFrame)
Value

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

(继承自 DoubleKeyFrame)

方法

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)

适用于

另请参阅