SplinePointKeyFrame 類別

定義

使用曲線插補,從上一個主要畫面格的 Point 值動畫到它自己的 Value

public ref class SplinePointKeyFrame 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 SplinePointKeyFrame 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 SplinePointKeyFrame 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 SplinePointKeyFrame : 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 SplinePointKeyFrame : PointKeyFrame
Public NotInheritable Class SplinePointKeyFrame
Inherits PointKeyFrame
<SplinePointKeyFrame .../>
繼承
Object Platform::Object IInspectable DependencyObject PointKeyFrame SplinePointKeyFrame
屬性

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

備註

主要畫面格動畫允許多個目標值,這些值會在動畫時間軸的某個時間到達。 換句話說,每個主要畫面格都可以指定不同的中繼值,最後一個到達的主要畫面格就是最終的動畫值。 在動畫中指定多個值可以製作更複雜的動畫。 您可以在相同的主要畫面格集合中混合離散、線性和曲線主要畫面格。

如需如何使用主要畫面格動畫的詳細資訊,請參閱 主要畫面格動畫和 Easing 函式動畫

建構函式

SplinePointKeyFrame()

初始化 SplinePointKeyFrame 類別的新實例。

屬性

Dispatcher

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

(繼承來源 DependencyObject)
KeySpline

取得或設定兩個控制點,這兩個控制點會定義這個主要畫面格的動畫進度。

KeySplineProperty

識別 KeySpline 相依性屬性。

KeyTime

取得或設定應該到達主要畫面格目標 Value 的時間。

(繼承來源 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)

適用於

另請參閱