DoubleAnimationUsingKeyFrames 類別

定義

以動畫顯示 Double 屬性的值,沿著一組主要畫面格。

public ref class DoubleAnimationUsingKeyFrames sealed : Timeline
/// [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)]
/// [Windows.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
class DoubleAnimationUsingKeyFrames final : Timeline
/// [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.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class DoubleAnimationUsingKeyFrames final : Timeline
[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)]
[Windows.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
public sealed class DoubleAnimationUsingKeyFrames : Timeline
[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.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class DoubleAnimationUsingKeyFrames : Timeline
Public NotInheritable Class DoubleAnimationUsingKeyFrames
Inherits Timeline
<DoubleAnimationUsingKeyFrames>
  oneOrMoreDoubleKeyFrames
</DoubleAnimationUsingKeyFrames>
繼承
Object Platform::Object IInspectable DependencyObject Timeline DoubleAnimationUsingKeyFrames
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

下列範例會讓矩形橫越畫面移動。 此範例使用DoubleAnimationUsingKeyFrames類別,以動畫顯示套用至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 Sub Start_Animation(ByVal sender As Object, ByVal e As EventArgs)
    myStoryboard.Begin()
End Sub
// Start the animation when the object loads
private void Start_Animation(object sender, RoutedEventArgs e)
{
    myStoryboard.Begin();
}

建構函式

DoubleAnimationUsingKeyFrames()

初始化 DoubleAnimationUsingKeyFrames 類別的新實例。

屬性

AutoReverse

取得或設定值,其中該值指出時間軸是否會在完成向前反覆項目後反向播放。

(繼承來源 Timeline)
BeginTime

取得或設定這個 時間軸 應該開始的時間。

(繼承來源 Timeline)
Dispatcher

取得這個 物件相關聯的 CoreDispatcherCoreDispatcher代表可在 UI 執行緒上存取DependencyObject的功能,即使程式碼是由非 UI 執行緒起始也一樣。

(繼承來源 DependencyObject)
Duration

取得或設定這個時間表播放的時間長度 (不計算重複次數)。

(繼承來源 Timeline)
EnableDependentAnimation

取得或設定值,這個值會宣告是否應該允許考慮相依動畫的動畫屬性使用此動畫宣告。

EnableDependentAnimationProperty

識別 EnableDependentAnimation 相依性屬性。

FillBehavior

取得或設定值,這個值會指定動畫在到達使用期間結束時的行為。

(繼承來源 Timeline)
KeyFrames

取得定義動畫的 DoubleKeyFrame 物件的集合。

RepeatBehavior

取得或設定這個時間軸的重複行為。

(繼承來源 Timeline)
SpeedRatio

取得或設定相對於其父系的速率,此時會進行這個 時間軸

(繼承來源 Timeline)

方法

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)

事件

Completed

發生于 Storyboard 物件已完成播放時。

(繼承來源 Timeline)

適用於

另請參閱