电子药箱通讯服务端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

DelegateCommand.cs 664B

před 7 měsíci
1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Input;
  7. namespace Tcp.Test2
  8. {
  9. public class DelegateCommand : ICommand
  10. {
  11. private Action _action;
  12. public DelegateCommand(Action action)
  13. {
  14. _action = action;
  15. }
  16. public event EventHandler? CanExecuteChanged;
  17. public bool CanExecute(object? parameter)
  18. {
  19. return true;
  20. }
  21. public void Execute(object? parameter)
  22. {
  23. if (_action != null)
  24. {
  25. _action();
  26. }
  27. }
  28. }
  29. }