using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; namespace ToolKit { public class RelayCommand : ICommand { public event EventHandler? CanExecuteChanged; private readonly Action execute; private readonly Func canExecute; public RelayCommand(Action execute,Func canExecute = null) { this.execute = execute; this.canExecute = canExecute; } public bool CanExecute(object? parameter) { if (parameter == null) return true; return canExecute((T)parameter); } public void Execute(object? parameter = null) { execute((T) parameter); } } }