Begin Animation - CSharp Windows.UI.Xaml.Media.Animation

CSharp examples for Windows.UI.Xaml.Media.Animation:Animation

Description

Begin Animation

Demo Code


using System.Windows.Media.Animation;
using System.Windows;
using System;//  w  w w.  jav  a 2  s .  co m

public class Main{
        public static void BeginAnimation(this DependencyObject obj, DependencyProperty property,
                                          DoubleAnimation animation, EventHandler completed)
        {
            var storyboard = new Storyboard();
            Storyboard.SetTargetProperty(storyboard, new PropertyPath(property));
            Storyboard.SetTarget(storyboard, obj);
            storyboard.Children.Add(animation);
            storyboard.Completed += completed;
            storyboard.Begin();
        }
        public static void BeginAnimation(this DependencyObject obj, DependencyProperty property,
                                          DoubleAnimation animation)
        {
            BeginAnimation(obj, property, animation, null);
        }
}

Related Tutorials