diff --git a/src/Avalonia.Xaml.Interactions.Custom/Animations/StartAnimationAction.cs b/src/Avalonia.Xaml.Interactions.Custom/Animations/StartAnimationAction.cs new file mode 100644 index 000000000..37cb0d34e --- /dev/null +++ b/src/Avalonia.Xaml.Interactions.Custom/Animations/StartAnimationAction.cs @@ -0,0 +1,43 @@ +using Avalonia.Controls; +using Avalonia.Xaml.Interactivity; + +namespace Avalonia.Xaml.Interactions; + +/// +/// +/// +public class StartAnimationAction : AvaloniaObject, IAction +{ + /// + /// + /// + public static readonly StyledProperty AnimationProperty = + AvaloniaProperty.Register(nameof(Animation)); + + /// + /// + /// + public Animation.Animation? Animation + { + get => GetValue(AnimationProperty); + set => SetValue(AnimationProperty, value); + } + + /// + /// + /// + /// + /// + /// + public object Execute(object? sender, object? parameter) + { + if (sender is not Control control || Animation is null) + { + return false; + } + + _ = Animation.RunAsync(control); + + return true; + } +}