SubmitDocsView.axaml.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Avalonia;
  2. using Avalonia.Controls;
  3. using Avalonia.Input;
  4. using Avalonia.Interactivity;
  5. using Avalonia.Markup.Xaml;
  6. namespace PRS.Avalonia.Modules;
  7. public partial class SubmitDocsView : UserControl
  8. {
  9. public SubmitDocsView()
  10. {
  11. InitializeComponent();
  12. }
  13. private Button? _heldButton;
  14. private void Button_Holding(object? sender, HoldingRoutedEventArgs e)
  15. {
  16. if (sender is not Button button || button.Tag is not DataEntryDocumentShell shell) return;
  17. if(e.HoldingState == HoldingState.Started)
  18. {
  19. _heldButton = button;
  20. (DataContext as SubmitDocsViewModel)?.HoldCommand.Execute(shell);
  21. }
  22. }
  23. private void Button_Click(object? sender, RoutedEventArgs e)
  24. {
  25. if (sender is not Button button || button.Tag is not DataEntryDocumentShell shell) return;
  26. if(button == _heldButton)
  27. {
  28. // Disable the click event if we held the button.
  29. _heldButton = null;
  30. return;
  31. }
  32. (DataContext as SubmitDocsViewModel)?.ClickCommand.Execute(shell);
  33. }
  34. }