public void BeginAnimation(DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior) { if (dp == null) { throw new ArgumentNullException("dp"); } if (animation != null && !animation.IsValidTarget(dp)) { throw new ArgumentException("AnimationTimeline type mismatch: " + animation.GetType() + " on property " + dp.OwnerType.GetType() + "." + dp.Name + " of type " + dp.PropertyType); } if (base.IsFrozen) { throw new InvalidOperationException("Resource is frozen and cannot be animated"); } if (animation == null) { base.ClearAnimation(dp); } else { Storyboard storyboard = new Storyboard(); storyboard.Children.Add(animation); storyboard.Begin(FrameworkElement.FindTreeElement(this), handoffBehavior); } }