internal static void SetAnimation(DependencyObject obj, AnimationBase value)
 {
     obj.SetValue(AnimationProperty, value == null ? null : new WeakReference(value));
 }
        public static bool Play(Control target, string animationName, Action completeCallback, params object[] args)
        {
            if ((!GetIsAnimationEnabled(target) || !IsGlobalAnimationEnabled) ||
                (VisualTreeHelper.GetChildrenCount(target) <= 0))
            {
                if (completeCallback != null)
                {
                    completeCallback();
                }
                return(false);
            }
            var child = VisualTreeHelper.GetChild(target, 0) as FrameworkElement;

            if (child != null)
            {
                var storyboard = child.Resources[animationName] as Storyboard;
                if (storyboard == null)
                {
                    var animationSelector = GetAnimationSelector(target);
                    if (animationSelector == null)
                    {
                        if (completeCallback != null)
                        {
                            completeCallback();
                        }
                        return(false);
                    }
                    var animation = animationSelector.SelectAnimation(target, animationName);
                    if (animation == null)
                    {
                        if (completeCallback != null)
                        {
                            completeCallback();
                        }
                        return(false);
                    }
                    storyboard = animation.CreateAnimation(target);
                    if (storyboard == null)
                    {
                        if (completeCallback != null)
                        {
                            completeCallback();
                        }
                        return(false);
                    }
                    storyboard.Completed += OnStoryboardCompleted;
                    SetAnimation(storyboard, animation);
                    child.Resources.Add(animationName, storyboard);
                }
                AnimationBase animation2 = GetAnimation(storyboard);
                if (completeCallback != null)
                {
                    AddCallback(storyboard, completeCallback);
                }
                if (storyboard.Children.Count > 0)
                {
                    animation2.UpdateAnimation(target, storyboard, args);
                }
                storyboard.Begin();
            }
            return(true);
        }