CloseNotificationAction.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Avalonia.Controls.Notifications;
  2. namespace Avalonia.Xaml.Interactions.Custom;
  3. /// <summary>
  4. ///
  5. /// </summary>
  6. public class CloseNotificationAction : Avalonia.Xaml.Interactivity.Action
  7. {
  8. /// <summary>
  9. ///
  10. /// </summary>
  11. public static readonly StyledProperty<NotificationCard?> NotificationCardProperty =
  12. AvaloniaProperty.Register<CloseNotificationAction, NotificationCard?>(nameof(NotificationCard));
  13. /// <summary>
  14. ///
  15. /// </summary>
  16. public NotificationCard? NotificationCard
  17. {
  18. get => GetValue(NotificationCardProperty);
  19. set => SetValue(NotificationCardProperty, value);
  20. }
  21. /// <summary>
  22. ///
  23. /// </summary>
  24. /// <param name="sender"></param>
  25. /// <param name="parameter"></param>
  26. /// <returns></returns>
  27. public override object Execute(object? sender, object? parameter)
  28. {
  29. if (!IsEnabled)
  30. {
  31. return false;
  32. }
  33. if (NotificationCard is null)
  34. {
  35. return false;
  36. }
  37. NotificationCard.Close();
  38. return true;
  39. }
  40. }