using System; using System.Windows.Input; namespace RKISPATTERN.Command { public class RelayCommand : ICommand { private Action execute; private Func canExecute; public RelayCommand(Action execute, Func canExecute = null) { this.execute = execute; this.canExecute = canExecute; } public event EventHandler? CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } public bool CanExecute(object? parameter) { return this.canExecute == null || this.canExecute(parameter); } public void Execute(object? parameter) { this.execute(parameter); } } }