/// <summary> /// Saturates the visual within the animation set. /// </summary> /// <param name="animationSet">The animation set.</param> /// <param name="value">The value. 0 is desaturated, 1 is saturated.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay in milliseconds.</param> /// <param name="easingType">The <see cref="EasingType"/></param> /// <returns>An animation set with saturation effects incorporated.</returns> public static AnimationSet Saturation( this AnimationSet animationSet, double value = 0d, double duration = 500d, double delay = 0d, EasingType easingType = EasingType.Default) { return(SaturationEffect.EffectAnimation(animationSet, value, duration, delay, easingType)); }
/// <summary> /// Animates the Gaussian blur of the UIElement. /// </summary> /// <param name="animationSet">The animation set.</param> /// <param name="value">The blur amount.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay. (ignored if duration == 0)</param> /// <param name="easingType">The easing function</param> /// <param name="easingMode">The easing mode</param> /// <returns> /// An Animation Set. /// </returns> public static AnimationSet Blur( this AnimationSet animationSet, double value = 0d, double duration = 500d, double delay = 0d, EasingType easingType = EasingType.Default, EasingMode easingMode = EasingMode.EaseOut) { return(BlurEffect.EffectAnimation(animationSet, value, duration, delay, easingType, easingMode)); }
/// <summary> /// Animates the opacity of the UIElement. /// </summary> /// <param name="animationSet">The animation set.</param> /// <param name="value">The fade value, between 0 and 1.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay. (ignored if duration == 0)</param> /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param> /// <param name="easingMode">The EasingMode to use to interpolate between keyframes.</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Fade( this AnimationSet animationSet, float value = 0f, double duration = 500d, double delay = 0d, EasingType easingType = EasingType.Default, EasingMode easingMode = EasingMode.EaseOut) { if (animationSet == null) { return(null); } if (!AnimationSet.UseComposition) { var animation = new DoubleAnimation { To = value, Duration = TimeSpan.FromMilliseconds(duration), BeginTime = TimeSpan.FromMilliseconds(delay), EasingFunction = GetEasingFunction(easingType, easingMode) }; animationSet.AddStoryboardAnimation("Opacity", animation); } else { if (duration <= 0) { animationSet.AddCompositionDirectPropertyChange("Opacity", value); return(animationSet); } var visual = animationSet.Visual; var compositor = visual?.Compositor; if (compositor == null) { return(null); } var animation = compositor.CreateScalarKeyFrameAnimation(); animation.Duration = TimeSpan.FromMilliseconds(duration); animation.DelayTime = TimeSpan.FromMilliseconds(delay); animation.InsertKeyFrame(1f, value, GetCompositionEasingFunction(easingType, compositor, easingMode)); animationSet.AddCompositionAnimation("Opacity", animation); } return(animationSet); }
/// <summary> /// Animates the opacity of the the UIElement. /// </summary> /// <param name="associatedObject">The UI Element to change the opacity of.</param> /// <param name="value">The fade value, between 0 and 1.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay. (ignored if duration == 0)</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Fade( this UIElement associatedObject, float value = 0f, double duration = 500d, double delay = 0d) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Fade(value, duration, delay)); }
ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3); // SDK >= 14393 /// <summary> /// Animates the gaussian blur of the the UIElement. /// </summary> /// <param name="associatedObject">The associated object.</param> /// <param name="value">The blur amount.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay. (ignored if duration == 0)</param> /// <returns> /// An Animation Set. /// </returns> /// <seealso cref="IsBlurSupported" /> public static AnimationSet Blur( this FrameworkElement associatedObject, double value = 0d, double duration = 500d, double delay = 0d) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Blur(value, duration, delay)); }
/// <summary> /// Animates a point light and it's distance. /// </summary> /// <param name="associatedObject">The associated object.</param> /// <param name="distance">The value.</param> /// <param name="duration">The duration.</param> /// <param name="delay">The delay.</param> /// <returns>An animation set.</returns> public static AnimationSet Light( this FrameworkElement associatedObject, double distance = 0d, double duration = 500d, double delay = 0d) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Light(distance, duration, delay)); }
/// <summary> /// Animates the offset of the the UIElement. /// </summary> /// <param name="associatedObject">The specified UI Element.</param> /// <param name="offsetX">The offset on the x axis.</param> /// <param name="offsetY">The offset on the y axis.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay in milliseconds. (ignored if duration == 0)</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Offset( this UIElement associatedObject, float offsetX = 0f, float offsetY = 0f, double duration = 500d, double delay = 0d) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Offset(offsetX, offsetY, duration, delay)); }
/// <summary> /// Saturates the FrameworkElement. /// </summary> /// <param name="associatedObject">The associated object.</param> /// <param name="value">The value, between 0 and 1. 0 is desaturated, 1 is saturated.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay in milliseconds.</param> /// <param name="easingType">The <see cref="EasingType"/></param> /// <returns>An animation set with saturation effects incorporated.</returns> public static AnimationSet Saturation( this FrameworkElement associatedObject, double value = 0d, double duration = 500d, double delay = 0d, EasingType easingType = EasingType.Default) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Saturation(value, duration, delay, easingType)); }
/// <summary> /// Animates a point light and it's distance. /// </summary> /// <param name="associatedObject">The associated object.</param> /// <param name="distance">The value.</param> /// <param name="duration">The duration.</param> /// <param name="delay">The delay.</param> /// <param name="color">The color of the spotlight.</param> /// <param name="easingType">The easing function</param> /// <returns>An animation set.</returns> public static AnimationSet Light( this FrameworkElement associatedObject, double distance = 0d, double duration = 500d, double delay = 0d, Color?color = null, EasingType easingType = EasingType.Default) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Light(distance, duration, delay, color, easingType)); }
/// <summary> /// Animates the opacity of the UIElement. /// </summary> /// <param name="associatedObject">The UI Element to change the opacity of.</param> /// <param name="value">The fade value, between 0 and 1.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay. (ignored if duration == 0)</param> /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param> /// <param name="easingMode">The easing mode to use to interpolate between keyframes.</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Fade( this UIElement associatedObject, float value = 0f, double duration = 500d, double delay = 0d, EasingType easingType = EasingType.Default, EasingMode easingMode = EasingMode.EaseOut) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Fade(value, duration, delay, easingType, easingMode)); }
/// <summary> /// Animates the offset of the UIElement. /// </summary> /// <param name="associatedObject">The specified UI Element.</param> /// <param name="offsetX">The offset on the x axis.</param> /// <param name="offsetY">The offset on the y axis.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay in milliseconds. (ignored if duration == 0)</param> /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param> /// <param name="easingMode">The EasingMode to use to interpolate between keyframes.</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Offset( this UIElement associatedObject, float offsetX = 0f, float offsetY = 0f, double duration = 500d, double delay = 0d, EasingType easingType = EasingType.Default, EasingMode easingMode = EasingMode.EaseOut) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Offset(offsetX, offsetY, duration, delay, easingType, easingMode)); }
/// <summary> /// Animates the scale of the the specified UIElement. /// </summary> /// <param name="associatedObject">The associated UIElement.</param> /// <param name="scaleX">The scale on the x axis.</param> /// <param name="scaleY">The scale on the y axis.</param> /// <param name="centerX">The center x in pixels.</param> /// <param name="centerY">The center y in pixels.</param> /// <param name="duration">The duration in millisecond.</param> /// <param name="delay">The delay in milliseconds. (ignored if duration == 0)</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Scale( this UIElement associatedObject, float scaleX = 1f, float scaleY = 1f, float centerX = 0f, float centerY = 0f, double duration = 500d, double delay = 0d) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Scale(scaleX, scaleY, centerX, centerY, duration, delay)); }
/// <summary> /// Animates the rotation in degrees of the the UIElement. /// </summary> /// <param name="associatedObject">The UI Element to rotate.</param> /// <param name="value">The value in degrees to rotate.</param> /// <param name="centerX">The center x in pixels.</param> /// <param name="centerY">The center y in pixels.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay in milliseconds. (ignored if duration == 0)</param> /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Rotate( this UIElement associatedObject, float value = 0f, float centerX = 0f, float centerY = 0f, double duration = 500d, double delay = 0d, EasingType easingType = EasingType.Default) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Rotate(value, centerX, centerY, duration, delay, easingType)); }
/// <summary> /// Animates the scale of the specified UIElement. /// </summary> /// <param name="associatedObject">The associated UIElement.</param> /// <param name="scaleX">The scale on the x axis.</param> /// <param name="scaleY">The scale on the y axis.</param> /// <param name="centerX">The center x in pixels.</param> /// <param name="centerY">The center y in pixels.</param> /// <param name="duration">The duration in millisecond.</param> /// <param name="delay">The delay in milliseconds. (ignored if duration == 0)</param> /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param> /// <param name="easingMode">The EasingMode to use to interpolate between keyframes.</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Scale( this UIElement associatedObject, float scaleX = 1f, float scaleY = 1f, float centerX = 0f, float centerY = 0f, double duration = 500d, double delay = 0d, EasingType easingType = EasingType.Default, EasingMode easingMode = EasingMode.EaseOut) { if (associatedObject == null) { return(null); } var animationSet = new AnimationSet(associatedObject); return(animationSet.Scale(scaleX, scaleY, centerX, centerY, duration, delay, easingType, easingMode)); }
/// <summary> /// Wait for existing animations to complete before running new animations /// </summary> /// <returns>AnimationSet to allow chaining</returns> public AnimationSet Then() { var savedAnimationSet = new AnimationSet(Element); savedAnimationSet._animations = _animations; savedAnimationSet._effectAnimations = _effectAnimations; savedAnimationSet._directPropertyChanges = _directPropertyChanges; savedAnimationSet._directEffectPropertyChanges = _directEffectPropertyChanges; savedAnimationSet._storyboard = _storyboard; savedAnimationSet._storyboardAnimations = _storyboardAnimations; _animationSets.Add(savedAnimationSet); _animations = new Dictionary <string, CompositionAnimation>(); _effectAnimations = new List <EffectAnimationDefinition>(); _directPropertyChanges = new Dictionary <string, object>(); _directEffectPropertyChanges = new List <EffectDirectPropertyChangeDefinition>(); _storyboard = new Storyboard(); _storyboardAnimations = new Dictionary <string, Timeline>(); return(this); }
/// <summary> /// Animates a point light and it's distance. /// </summary> /// <param name="animationSet">The animation set.</param> /// <param name="distance">The distance of the light.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay. (ignored if duration == 0)</param> /// <seealso cref="IsLightingSupported" /> /// <returns> /// An Animation Set. /// </returns> public static AnimationSet Light( this AnimationSet animationSet, double distance = 0d, double duration = 500d, double delay = 0d) { if (!IsLightingSupported) { return(null); } if (animationSet == null) { return(null); } var visual = animationSet.Visual; var associatedObject = animationSet.Element as FrameworkElement; if (associatedObject == null) { return(animationSet); } var compositor = visual?.Compositor; if (compositor == null) { return(null); } var task = new AnimationTask(); task.AnimationSet = animationSet; task.Task = DispatcherHelper.ExecuteOnUIThreadAsync( () => { const string sceneName = "PointLightScene"; PointLight pointLight; CompositionDrawingSurface normalMap = null; if (!pointLights.ContainsKey(visual)) { SurfaceLoader.Initialize(compositor); normalMap = SurfaceLoader.LoadText(string.Empty, new Windows.Foundation.Size(512, 512), new Graphics.Canvas.Text.CanvasTextFormat(), Colors.Transparent, Colors.Transparent); } if (pointLights.ContainsKey(visual)) { pointLight = pointLights[visual]; } else { pointLight = compositor.CreatePointLight(); var normalBrush = compositor.CreateSurfaceBrush(normalMap); normalBrush.Stretch = CompositionStretch.Fill; // check to see if the visual already has a point light applied. var spriteVisual = ElementCompositionPreview.GetElementChildVisual(associatedObject) as SpriteVisual; var normalsBrush = spriteVisual?.Brush as CompositionEffectBrush; if (normalsBrush == null || normalsBrush.Comment != sceneName) { var lightEffect = new CompositeEffect() { Mode = CanvasComposite.Add, Sources = { new CompositionEffectSourceParameter("ImageSource"), new SceneLightingEffect() { Name = sceneName, AmbientAmount = 0, DiffuseAmount = 0.5f, SpecularAmount = 0, NormalMapSource = new CompositionEffectSourceParameter("NormalMap"), } } }; var effectFactory = compositor.CreateEffectFactory(lightEffect); var brush = effectFactory.CreateBrush(); brush.SetSourceParameter("NormalMap", normalBrush); var sprite = compositor.CreateSpriteVisual(); sprite.Size = visual.Size; sprite.Brush = brush; sprite.Comment = sceneName; ElementCompositionPreview.SetElementChildVisual(task.AnimationSet.Element, sprite); pointLight.CoordinateSpace = visual; pointLight.Targets.Add(visual); } } var delayTime = task.Delay != null ? task.Delay.Value : TimeSpan.FromMilliseconds(delay); var durationTime = task.Duration != null ? task.Duration.Value : TimeSpan.FromMilliseconds(duration); if (durationTime.TotalMilliseconds <= 0) { task.AnimationSet.AddEffectDirectPropertyChange(pointLight, (float)distance, nameof(pointLight.Offset)); } else { var diffuseAnimation = compositor.CreateVector3KeyFrameAnimation(); diffuseAnimation.InsertKeyFrame(1f, new System.Numerics.Vector3(visual.Size.X / 2, visual.Size.Y / 2, (float)distance)); diffuseAnimation.Duration = durationTime; diffuseAnimation.DelayTime = delayTime; task.AnimationSet.AddCompositionEffectAnimation(pointLight, diffuseAnimation, nameof(pointLight.Offset)); } pointLights[visual] = pointLight; }, Windows.UI.Core.CoreDispatcherPriority.Normal); animationSet.AddAnimationThroughTask(task); return(animationSet); }
/// <summary> /// Animates the gaussian blur of the the UIElement. /// </summary> /// <param name="animationSet">The animation set.</param> /// <param name="value">The blur amount.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay. (ignored if duration == 0)</param> /// <returns> /// An Animation Set. /// </returns> /// <seealso cref="IsBlurSupported" /> public static AnimationSet Blur( this AnimationSet animationSet, double value = 0d, double duration = 500d, double delay = 0d) { if (animationSet == null) { return(null); } if (!IsBlurSupported) { // The operating system doesn't support blur. // Fail gracefully by not applying blur. // See 'IsBlurSupported' property return(null); } var visual = animationSet.Visual; var associatedObject = animationSet.Element as FrameworkElement; if (associatedObject == null) { return(animationSet); } var compositor = visual?.Compositor; const string blurName = "Blur"; if (compositor == null) { return(null); } // check to see if the visual already has a blur applied. var spriteVisual = ElementCompositionPreview.GetElementChildVisual(associatedObject) as SpriteVisual; var blurBrush = spriteVisual?.Brush as CompositionEffectBrush; if (blurBrush == null || blurBrush.Comment != blurName) { var blurEffect = new GaussianBlurEffect { Name = blurName, BlurAmount = 0f, Optimization = EffectOptimization.Balanced, BorderMode = EffectBorderMode.Hard, Source = new CompositionEffectSourceParameter("source") }; // Create a brush to which I want to apply. I also have noted that BlurAmount should be left out of the compiled shader. blurBrush = compositor.CreateEffectFactory(blurEffect, new[] { $"{blurName}.BlurAmount" }).CreateBrush(); blurBrush.Comment = blurName; // Set the source of the blur as a backdrop brush blurBrush.SetSourceParameter("source", compositor.CreateBackdropBrush()); var blurSprite = compositor.CreateSpriteVisual(); blurSprite.Brush = blurBrush; ElementCompositionPreview.SetElementChildVisual(associatedObject, blurSprite); blurSprite.Size = new Vector2((float)associatedObject.ActualWidth, (float)associatedObject.ActualHeight); associatedObject.SizeChanged += (s, e) => { blurSprite.Size = new Vector2((float)associatedObject.ActualWidth, (float)associatedObject.ActualHeight); }; } if (duration <= 0) { animationSet.AddEffectDirectPropertyChange(blurBrush, (float)value, $"{blurName}.BlurAmount"); } else { // Create an animation to change the blur amount over time var blurAnimation = compositor.CreateScalarKeyFrameAnimation(); blurAnimation.InsertKeyFrame(1f, (float)value); blurAnimation.Duration = TimeSpan.FromMilliseconds(duration); blurAnimation.DelayTime = TimeSpan.FromMilliseconds(delay); animationSet.AddCompositionEffectAnimation(blurBrush, blurAnimation, $"{blurName}.BlurAmount"); } if (value == 0) { animationSet.Completed += AnimationSet_Completed; } return(animationSet); }
/// <summary> /// Animates the offset of the the UIElement. /// </summary> /// <param name="animationSet">The animation set.</param> /// <param name="offsetX">The offset on the x axis.</param> /// <param name="offsetY">The offset on the y axis.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay in milliseconds. (ignored if duration == 0)</param> /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Offset( this AnimationSet animationSet, float offsetX = 0f, float offsetY = 0f, double duration = 500d, double delay = 0d, EasingType easingType = EasingType.Default) { if (animationSet == null) { return(null); } if (!AnimationSet.UseComposition) { var element = animationSet.Element; var transform = GetAttachedCompositeTransform(element); var animationX = new DoubleAnimation(); var animationY = new DoubleAnimation(); animationX.To = offsetX; animationY.To = offsetY; animationX.Duration = animationY.Duration = TimeSpan.FromMilliseconds(duration); animationX.BeginTime = animationY.BeginTime = TimeSpan.FromMilliseconds(delay); animationX.EasingFunction = animationY.EasingFunction = GetEasingFunction(easingType); animationSet.AddStoryboardAnimation(GetAnimationPath(transform, element, "TranslateX"), animationX); animationSet.AddStoryboardAnimation(GetAnimationPath(transform, element, "TranslateY"), animationY); } else { var visual = animationSet.Visual; var offsetVector = new Vector3(offsetX, offsetY, 0); if (duration <= 0) { animationSet.AddCompositionDirectPropertyChange("Offset", offsetVector); return(animationSet); } var compositor = visual?.Compositor; if (compositor == null) { return(null); } var animation = compositor.CreateVector3KeyFrameAnimation(); animation.Duration = TimeSpan.FromMilliseconds(duration); animation.DelayTime = TimeSpan.FromMilliseconds(delay); if (easingType == EasingType.Default) { animation.InsertKeyFrame(1f, offsetVector); } else { animation.InsertKeyFrame(1f, offsetVector, GetCompositionEasingFunction(easingType, compositor)); } animationSet.AddCompositionAnimation("Offset", animation); } return(animationSet); }
/// <summary> /// Animates the rotation in degrees of the UIElement. /// </summary> /// <param name="animationSet">The animation set.</param> /// <param name="value">The value in degrees to rotate.</param> /// <param name="centerX">The center x in pixels.</param> /// <param name="centerY">The center y in pixels.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay in milliseconds. (ignored if duration == 0)</param> /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param> /// <param name="easingMode">The EasingMode to use to interpolate between keyframes.</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Rotate( this AnimationSet animationSet, float value = 0f, float centerX = 0f, float centerY = 0f, double duration = 500d, double delay = 0d, EasingType easingType = EasingType.Default, EasingMode easingMode = EasingMode.EaseOut) { if (animationSet == null) { return(null); } if (!AnimationSet.UseComposition) { var element = animationSet.Element; var transform = GetAttachedCompositeTransform(element); transform.CenterX = centerX; transform.CenterY = centerY; var animation = new DoubleAnimation { To = value, Duration = TimeSpan.FromMilliseconds(duration), BeginTime = TimeSpan.FromMilliseconds(delay), EasingFunction = GetEasingFunction(easingType, easingMode) }; animationSet.AddStoryboardAnimation(GetAnimationPath(transform, element, "Rotation"), animation); } else { var visual = animationSet.Visual; visual.CenterPoint = new Vector3(centerX, centerY, 0); if (duration <= 0) { animationSet.AddCompositionDirectPropertyChange("RotationAngleInDegrees", value); return(animationSet); } var compositor = visual.Compositor; if (compositor == null) { return(null); } var animation = compositor.CreateScalarKeyFrameAnimation(); animation.Duration = TimeSpan.FromMilliseconds(duration); animation.DelayTime = TimeSpan.FromMilliseconds(delay); animation.InsertKeyFrame(1f, value, GetCompositionEasingFunction(easingType, compositor, easingMode)); animationSet.AddCompositionAnimation("RotationAngleInDegrees", animation); } return(animationSet); }
/// <summary> /// Animates the scale of the the specified UIElement. /// </summary> /// <param name="animationSet">The animationSet object.</param> /// <param name="scaleX">The scale on the x axis.</param> /// <param name="scaleY">The scale on the y axis.</param> /// <param name="centerX">The center x in pixels.</param> /// <param name="centerY">The center y in pixels.</param> /// <param name="duration">The duration in milliseconds.</param> /// <param name="delay">The delay in milliseconds. (ignored if duration == 0)</param> /// <returns> /// An AnimationSet. /// </returns> public static AnimationSet Scale( this AnimationSet animationSet, float scaleX = 1f, float scaleY = 1f, float centerX = 0f, float centerY = 0f, double duration = 500d, double delay = 0d) { if (animationSet == null) { return(null); } if (!AnimationSet.UseComposition) { var element = animationSet.Element; var transform = GetAttachedCompositeTransform(element); transform.CenterX = centerX; transform.CenterY = centerY; var animationX = new DoubleAnimation(); var animationY = new DoubleAnimation(); animationX.To = scaleX; animationY.To = scaleY; animationX.Duration = animationY.Duration = TimeSpan.FromMilliseconds(duration); animationX.BeginTime = animationY.BeginTime = TimeSpan.FromMilliseconds(delay); animationX.EasingFunction = animationY.EasingFunction = _defaultStoryboardEasingFunction; animationSet.AddStoryboardAnimation(GetAnimationPath(transform, element, "ScaleX"), animationX); animationSet.AddStoryboardAnimation(GetAnimationPath(transform, element, "ScaleY"), animationY); } else { var visual = animationSet.Visual; visual.CenterPoint = new Vector3(centerX, centerY, 0); var scaleVector = new Vector3(scaleX, scaleY, 1.0f); if (duration <= 0) { animationSet.AddCompositionDirectPropertyChange("Scale", scaleVector); return(animationSet); } var compositor = visual.Compositor; if (compositor == null) { return(null); } var animation = compositor.CreateVector3KeyFrameAnimation(); animation.Duration = TimeSpan.FromMilliseconds(duration); animation.DelayTime = TimeSpan.FromMilliseconds(delay); animation.InsertKeyFrame(1f, scaleVector); animationSet.AddCompositionAnimation("Scale", animation); } return(animationSet); }