Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UIElement.BeginAnimation Method (DependencyProperty, AnimationTimeline)

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

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)

public void BeginAnimation(
	DependencyProperty dp,
	AnimationTimeline animation
)
You cannot use methods in XAML.

Parameters

dp
Type: System.Windows.DependencyProperty

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

animation
Type: System.Windows.Media.Animation.AnimationTimeline

The timeline of the animation to start.

Implements

IAnimatable.BeginAnimation(DependencyProperty, AnimationTimeline)

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.

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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

Show:
© 2014 Microsoft