Action.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. namespace Avalonia.Xaml.Interactivity;
  2. /// <summary>
  3. /// A base class for action that calls a method on a specified object when invoked.
  4. /// </summary>
  5. public abstract class Action : AvaloniaObject, IAction
  6. {
  7. /// <summary>
  8. /// Identifies the <seealso cref="IsEnabled"/> avalonia property.
  9. /// </summary>
  10. public static readonly StyledProperty<bool> IsEnabledProperty =
  11. AvaloniaProperty.Register<Avalonia.Xaml.Interactivity.Action, bool>(nameof(IsEnabled), defaultValue: true);
  12. /// <summary>
  13. /// Gets or sets a value indicating whether this instance is enabled.
  14. /// </summary>
  15. /// <value><c>true</c> if this instance is enabled; otherwise, <c>false</c>.</value>
  16. public bool IsEnabled
  17. {
  18. get => GetValue(IsEnabledProperty);
  19. set => SetValue(IsEnabledProperty, value);
  20. }
  21. /// <summary>
  22. /// Executes the action.
  23. /// </summary>
  24. /// <param name="sender">The <see cref="object"/> that is passed to the action by the behavior. Generally this is <seealso cref="IBehavior.AssociatedObject"/> or a target object.</param>
  25. /// <param name="parameter">The value of this parameter is determined by the caller.</param>
  26. /// <remarks> An example of parameter usage is EventTriggerBehavior, which passes the EventArgs as a parameter to its actions.</remarks>
  27. /// <returns>Returns the result of the action.</returns>
  28. public abstract object? Execute(object? sender, object? parameter);
  29. }