Language

UIElement.BeginAnimation メソッド

定義

この要素の指定したアニメーション化されたプロパティのアニメーションを開始します。

オーバーロード

名前 説明
BeginAnimation(DependencyProperty, AnimationTimeline)

この要素の指定したアニメーション化されたプロパティのアニメーションを開始します。

BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior)

プロパティに実行中のアニメーションが既に存在する場合の動作を指定するオプションを使用して、この要素で指定したアニメーション化されたプロパティの特定のアニメーションを開始します。

BeginAnimation(DependencyProperty, AnimationTimeline)

この要素の指定したアニメーション化されたプロパティのアニメーションを開始します。

public:
 virtual void BeginAnimation(System::Windows::DependencyProperty ^ dp, System::Windows::Media::Animation::AnimationTimeline ^ animation);
public void BeginAnimation(System.Windows.DependencyProperty dp, System.Windows.Media.Animation.AnimationTimeline animation);
abstract member BeginAnimation : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationTimeline -> unit
override this.BeginAnimation : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationTimeline -> unit
Public Sub BeginAnimation (dp As DependencyProperty, animation As AnimationTimeline)

パラメーター

dp
DependencyProperty

アニメーション化するプロパティ。依存関係プロパティ識別子として指定されます。

animation
AnimationTimeline

開始するアニメーションのタイムライン。

実装

例

次の例では、アニメーションを作成して割り当て、 BeginAnimation を呼び出して開始します。

// Animate the button's width.
DoubleAnimation widthAnimation = 
    new DoubleAnimation(120, 300, TimeSpan.FromSeconds(5));
widthAnimation.RepeatBehavior = RepeatBehavior.Forever;
widthAnimation.AutoReverse = true;
animatedButton.BeginAnimation(Button.WidthProperty, widthAnimation);
' Animate the button's width.
Dim widthAnimation As New DoubleAnimation(120, 300, TimeSpan.FromSeconds(5))
widthAnimation.RepeatBehavior = RepeatBehavior.Forever
widthAnimation.AutoReverse = True
animatedButton.BeginAnimation(Button.WidthProperty, widthAnimation)

注釈

プロパティがアニメーション化されているかどうかを確認すると、アニメーションが開始され、アニメーション化されていない開始点を超える最初のフレームがレンダリングされるときにアニメーション化されたと見なされることに注意してください。

BeginTimeのanimationがnullされている場合は、現在のアニメーションが削除され、プロパティの現在の値が保持されます。

animation値全体がnullされている場合、すべてのアニメーションがプロパティから削除され、プロパティ値は基本値に戻ります。 ただし、最初に関連付けられたアニメーション タイムラインは停止しません。 そのタイムラインに割り当てられているその他のアニメーションは引き続き実行されます。

適用対象

BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior)

プロパティに実行中のアニメーションが既に存在する場合の動作を指定するオプションを使用して、この要素で指定したアニメーション化されたプロパティの特定のアニメーションを開始します。

public:
 virtual void BeginAnimation(System::Windows::DependencyProperty ^ dp, System::Windows::Media::Animation::AnimationTimeline ^ animation, System::Windows::Media::Animation::HandoffBehavior handoffBehavior);
public void BeginAnimation(System.Windows.DependencyProperty dp, System.Windows.Media.Animation.AnimationTimeline animation, System.Windows.Media.Animation.HandoffBehavior handoffBehavior);
abstract member BeginAnimation : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationTimeline * System.Windows.Media.Animation.HandoffBehavior -> unit
override this.BeginAnimation : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationTimeline * System.Windows.Media.Animation.HandoffBehavior -> unit
Public Sub BeginAnimation (dp As DependencyProperty, animation As AnimationTimeline, handoffBehavior As HandoffBehavior)

パラメーター

dp
DependencyProperty

アニメーション化するプロパティ。依存関係プロパティ識別子として指定されます。

animation
AnimationTimeline

適用するアニメーションのタイムライン。

handoffBehavior
HandoffBehavior

プロパティ値に既に影響を与える現在の (実行中の) アニメーションと新しいアニメーションがどのように対話するかを指定する列挙体の値。

実装

例

次の例では、リソースから既存のアニメーションを取得し、指定したハンドオフ動作で BeginAnimation を呼び出すハンドラーを実装します。

private void myFrameNavigated(object sender, NavigationEventArgs args)
{
    DoubleAnimation myFadeInAnimation = (DoubleAnimation)this.Resources["MyFadeInAnimationResource"];
    myFrame.BeginAnimation(Frame.OpacityProperty, myFadeInAnimation, HandoffBehavior.SnapshotAndReplace);
}
Private Sub myFrameNavigated(ByVal sender As Object, ByVal args As NavigationEventArgs)
    Dim myFadeInAnimation As DoubleAnimation = CType(Me.Resources("MyFadeInAnimationResource"), DoubleAnimation)
    myFrame.BeginAnimation(Frame.OpacityProperty, myFadeInAnimation, HandoffBehavior.SnapshotAndReplace)
End Sub

注釈

プロパティがアニメーション化されているかどうかを確認すると、アニメーションが開始され、アニメーション化されていない開始点を超える最初のフレームがレンダリングされるときにアニメーション化されたと見なされることに注意してください。

BeginTimeのanimationがnullされている場合は、現在のアニメーションが削除され、プロパティの現在の値が保持されます。

animation値全体がnullされている場合、すべてのアニメーションがプロパティから削除され、プロパティ値は基本値に戻ります。 ただし、最初に関連付けられたアニメーション タイムラインは停止しません。 そのタイムラインに割り当てられているその他のアニメーションは引き続き実行されます。

適用対象