Uredi

Deli z drugimi prek


UIElement.BeginAnimation Method

Definition

Starts an animation for a specified animated property on this element.

Overloads

BeginAnimation(DependencyProperty, AnimationTimeline)

Starts an animation for a specified animated property on this element.

BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior)

Starts a specific animation for a specified animated property on this element, with the option of specifying what happens if the property already has a running animation.

BeginAnimation(DependencyProperty, AnimationTimeline)

Starts an animation for a specified animated property on this element.

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)

Parameters

dp
DependencyProperty

The property to animate, which is specified as a dependency property identifier.

animation
AnimationTimeline

The timeline of the animation to start.

Implements

Examples

The following example creates an animation, assigns it, and then calls BeginAnimation to start it.

// 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)

Remarks

When you check whether a property is animated, note that the animation will begin and be considered animated when the first frame beyond the non-animated starting point is rendered.

If the BeginTime for animation is null, then any current animations are removed and the current value of the property is held.

If the entire animation value is null, all animations are removed from the property and the property value reverts to its base value. However, the originally associated animation timeline is not stopped. Any other animations assigned to that timeline will continue to run.

Applies to

BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior)

Starts a specific animation for a specified animated property on this element, with the option of specifying what happens if the property already has a running animation.

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)

Parameters

dp
DependencyProperty

The property to animate, which is specified as the dependency property identifier.

animation
AnimationTimeline

The timeline of the animation to be applied.

handoffBehavior
HandoffBehavior

A value of the enumeration that specifies how the new animation interacts with any current (running) animations that are already affecting the property value.

Implements

Examples

The following example implements a handler that obtains an existing animation from a resource and then calls BeginAnimation with a specified handoff behavior.

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

Remarks

When you check whether a property is animated, note that the animation will begin and be considered animated when the first frame beyond the non-animated starting point is rendered.

If the BeginTime for animation is null, then any current animations are removed and the current value of the property is held.

If the entire animation value is null, all animations are removed from the property and the property value reverts to its base value. However, the originally associated animation timeline is not stopped. Any other animations assigned to that timeline will continue to run.

Applies to