XAML-Map-Control/MapControl/WinUI/Animatable.WinUI.cs

36 lines
1.1 KiB
C#
Raw Normal View History

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2024-02-03 21:01:53 +01:00
// Copyright © 2024 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
2021-06-14 21:41:37 +02:00
#if WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media.Animation;
#else
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media.Animation;
2021-06-14 21:41:37 +02:00
#endif
namespace MapControl
{
2021-01-17 23:46:24 +01:00
internal static class Animatable
{
2024-05-21 13:51:10 +02:00
public static void BeginAnimation(this DependencyObject obj, string property, Timeline animation)
{
2024-05-21 13:51:10 +02:00
Storyboard.SetTargetProperty(animation, property);
Storyboard.SetTarget(animation, obj);
2024-05-21 13:51:10 +02:00
var storyboard = new Storyboard();
storyboard.Children.Add(animation);
storyboard.Begin();
}
2017-08-04 21:38:58 +02:00
2024-05-21 13:51:10 +02:00
public static void BeginAnimation(this DependencyObject obj, DependencyProperty property, Timeline animation)
{
if (animation != null && property == UIElement.OpacityProperty)
{
BeginAnimation(obj, nameof(UIElement.Opacity), animation);
}
}
}
}