/// <summary> /// Apply Opacity animation to an object /// </summary> /// <param name="objectToAnimate">Object to animate</param> /// <param name="parentObj">Storyboard parent Object</param> /// <param name="storyboard">Storyboard reference</param> /// <param name="beginTime">Begin time</param> /// <param name="duration">Animation duration</param> /// <param name="targetValue">Target opacity value</param> /// <returns>Storyboard</returns> internal static Storyboard ApplyPropertyAnimation(DependencyObject objectToAnimate, String property, FrameworkElement parentObj, Storyboard storyboard, Double beginTime, Double[] timeCollection, Double[] valueCollection, List <KeySpline> splain) { if (objectToAnimate != null && parentObj != null) { DoubleCollection values = Graphics.GenerateDoubleCollection(valueCollection); DoubleCollection frameTimes = Graphics.GenerateDoubleCollection(timeCollection); DoubleAnimationUsingKeyFrames animation = AnimationHelper.CreateDoubleAnimation(parentObj, objectToAnimate, property, beginTime, frameTimes, values, splain); storyboard.Children.Add(animation); } return(storyboard); }
/// <summary> /// Apply Opacity animation to an object /// </summary> /// <param name="objectToAnimate">Object to animate</param> /// <param name="parentObj">Storyboard parent Object</param> /// <param name="storyboard">Storyboard reference</param> /// <param name="beginTime">Begin time</param> /// <param name="duration">Animation duration</param> /// <param name="targetValue">Target opacity value</param> /// <returns>Storyboard</returns> internal static Storyboard ApplyOpacityAnimation(FrameworkElement objectToAnimate, FrameworkElement parentObj, Storyboard storyboard, Double beginTime, Double duration, Double fromValue, Double targetValue) { if (objectToAnimate != null && parentObj != null) { DoubleCollection values = Graphics.GenerateDoubleCollection(fromValue, targetValue); DoubleCollection frameTimes = Graphics.GenerateDoubleCollection(0, duration); List <KeySpline> splines = GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 0), new Point(0.5, 1) ); objectToAnimate.Opacity = fromValue; DoubleAnimationUsingKeyFrames opacityAnimation = AnimationHelper.CreateDoubleAnimation(parentObj, objectToAnimate, "(UIElement.Opacity)", beginTime + 0.5, frameTimes, values, splines); storyboard.Children.Add(opacityAnimation); } return(storyboard); }