StoryboardExtensions.cs 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using Windows.UI.Xaml;
  3. using Windows.UI.Xaml.Media.Animation;
  4. namespace FormulaOneApp.Classic.Windows.Controls.Tile.Animations
  5. {
  6. public static class StoryboardExtensions
  7. {
  8. public static Storyboard AddToStoryboard(this Storyboard storyboard, Double fromOffset, double toOffset,
  9. Duration animationDuration, DependencyObject target, string targetProperty, EasingFunctionBase easingFunction = null)
  10. {
  11. var animationSnap = new DoubleAnimation
  12. {
  13. EnableDependentAnimation = true,
  14. From = fromOffset,
  15. To = toOffset,
  16. Duration = animationDuration,
  17. EasingFunction = easingFunction ?? new ExponentialEase { EasingMode = EasingMode.EaseOut, Exponent = 8d }
  18. };
  19. storyboard.Children.Add(animationSnap);
  20. Storyboard.SetTarget(animationSnap, target);
  21. Storyboard.SetTargetProperty(animationSnap, targetProperty);
  22. return storyboard;
  23. }
  24. }
  25. }