电子药箱通讯服务端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

DelegateCommand.cs 664B

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. }