using System; namespace ZeroLevel.WPF { public class RelayCommand : System.Windows.Input.ICommand { private readonly Predicate _canExecute; private readonly Action _execute; public RelayCommand(Predicate canExecute, Action execute) { _canExecute = canExecute; _execute = execute; } public event EventHandler CanExecuteChanged { add => System.Windows.Input.CommandManager.RequerySuggested += value; remove => System.Windows.Input.CommandManager.RequerySuggested -= value; } public bool CanExecute(object parameter) { return _canExecute(parameter); } public void Execute(object parameter) { _execute(parameter); } } }