public static void AnimatePropertyFromTo(DependencyObject target, DependencyProperty property, double?fromValue, double?targetValue, int duration, DoubleAnimation animation, EventHandler animationDone, int startTime) { if (property.PropertyType != typeof(double)) { throw new ArgumentException("property"); } if (!(target is IAnimatable)) { throw new ArgumentException("target"); } animation.From = fromValue; animation.To = targetValue; animation.BeginTime = TimeSpan.FromMilliseconds(startTime); animation.Duration = TimeSpan.FromMilliseconds(duration); if (animationDone != null) { animation.AttachCompletedEventHandler(animationDone); } AnimateProperty(target, property, animation, animationDone); }