Share via


ColorAnimationUsingKeyFrames クラス

定義

一連のキー フレームに沿って Color プロパティの値をアニメーション化します。

public ref class ColorAnimationUsingKeyFrames sealed : Timeline
/// [Microsoft.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
/// [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 ColorAnimationUsingKeyFrames final : Timeline
[Microsoft.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
[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 ColorAnimationUsingKeyFrames : Timeline
Public NotInheritable Class ColorAnimationUsingKeyFrames
Inherits Timeline
<ColorAnimationUsingKeyFrames ...>
  oneOrMoreColorKeyFrames
</ColorAnimationUsingKeyFrames>
継承
Object Platform::Object IInspectable DependencyObject Timeline ColorAnimationUsingKeyFrames
属性

次の例では、ColorAnimationUsingKeyFrames クラスを使用して、StackPanelBackground プロパティをアニメーション化します。 このアニメーションは、次の方法で 3 つのキー フレームを使用します。

  1. 最初の 2 秒の間に、 LinearColorKeyFrame は 徐々に緑から赤に色を変更します。 LinearColorKeyFrame などの線形キー フレームは、値間の滑らかな線形遷移を作成します。
  2. 次の 5 分の 1 秒が終了すると、 DiscreteColorKeyFrame によって色が赤から黄色にすばやく変わります。 DiscreteColorKeyFrame のような不連続のキー フレームは、値間の急激な変更を作成します。アニメーションはすぐに発生し、値間の補間はまったく行われません。
  3. 最後の 2 秒間に 、SplineColorKeyFrame によって色が再び変更されます。今回は黄色から緑色に戻ります。 SplineColorKeyFrame などのスプライン キー フレームは、KeySpline プロパティの値に従って値間の可変遷移を作成します。 KeySpline は、アニメーション期間中の時間と値の関係を非線形に変更する方法を提供します。特に、リレーションシップは個々のキー フレームでは生成が困難な曲線である可能性があります。 この例では、色の変化は最初はゆっくりしていますが、時間セグメントの終点に向かって急激に速くなります。
<StackPanel x:Name="myStackPanel" Background="Red"
Loaded="Start_Animation">
    <StackPanel.Resources>
        <Storyboard x:Name="colorStoryboard">

            <ColorAnimationUsingKeyFrames Storyboard.TargetName="myStackPanel" 
      Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                
                <!-- Go from green to red in the first 2 seconds. LinearColorKeyFrame creates
                a smooth, linear animation between values. -->
                <LinearColorKeyFrame Value="Blue" KeyTime="00:00:02" />

                <!-- In the next half second, go to yellow. DiscreteColorKeyFrame creates a 
                sudden jump between values. -->
                <DiscreteColorKeyFrame Value="Yellow" KeyTime="00:00:2.5" />

                <!-- In the final 2 seconds of the animation, go from yellow back to green. SplineColorKeyFrame 
                creates a variable transition between values depending on the KeySpline property. In this example,
                the animation starts off slow but toward the end of the time segment, it speeds up exponentially.-->
                <SplineColorKeyFrame Value="Green" KeyTime="00:00:4.5" KeySpline="0.6,0.0 0.9,0.00" />

            </ColorAnimationUsingKeyFrames>
        </Storyboard>
    </StackPanel.Resources>
</StackPanel>
// Start the animation when the object loads
private void Start_Animation(object sender, RoutedEventArgs e)
{
    colorStoryboard.Begin();
}

コンストラクター

ColorAnimationUsingKeyFrames()

ColorAnimationUsingKeyFrames クラスの新しいインスタンスを初期化します。

プロパティ

AutoReverse

順方向の反復の完了後に、タイムラインを逆方向に再生するかどうかを示す値を取得または設定します。

(継承元 Timeline)
BeginTime

この タイムライン を開始する時刻を取得または設定します。

(継承元 Timeline)
Dispatcher

常に Windows アプリ SDK アプリで を返しますnull。 代わりに DispatcherQueue を使用してください。

(継承元 DependencyObject)
DispatcherQueue

このオブジェクトが DispatcherQueue 関連付けられている を取得します。 は DispatcherQueue 、コードが UI 以外のスレッドによって開始された場合でも、UI スレッド上の にアクセス DependencyObject できる機能を表します。

(継承元 DependencyObject)
Duration

繰り返しをカウントせずに、このタイムラインの再生に要する時間を取得または設定します。

(継承元 Timeline)
EnableDependentAnimation

依存アニメーションと見なされるアニメーションプロパティに、このアニメーション宣言の使用を許可するかどうかを宣言する値を取得または設定します。

EnableDependentAnimationProperty

EnableDependentAnimation 依存関係プロパティを識別します。

FillBehavior

アニメーションがアクティブな期間の終わりに達した後の動作を示す値を取得または設定します。

(継承元 Timeline)
KeyFrames

アニメーションを定義する ColorKeyFrame オブジェクトのコレクションを取得します。

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)

適用対象

こちらもご覧ください