RelayComand.cs 815 B

1234567891011121314151617181920212223242526272829303132333435
  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 MvvmScaffoldFrame48.ViewModel
  8. {
  9. public class RelayCommand : ICommand
  10. {
  11. public event EventHandler CanExecuteChanged;
  12. private Action<object> _Excute { get; set; }
  13. private Predicate<object> _CanExcute { get; set; }
  14. public RelayCommand(Action<object> ExcuteMethod, Predicate<object> CanExcuteMethod)
  15. {
  16. _Excute = ExcuteMethod;
  17. _CanExcute = CanExcuteMethod;
  18. }
  19. public bool CanExecute(object parameter)
  20. {
  21. return _CanExcute(parameter);
  22. }
  23. public void Execute(object parameter)
  24. {
  25. _Excute(parameter);
  26. }
  27. }
  28. }