namespace FahzeugWPF; using System.Diagnostics; using System.Windows.Input; public class RelayCommand : ICommand { readonly Action _execute = null; readonly Predicate _canExecute = null; public RelayCommand(Action execute) : this(execute, null) { // Nothing to do } public RelayCommand(Action execute, Predicate canExecute) { if (execute == null) { throw new ArgumentNullException("execute"); } this._execute = execute; this._canExecute = canExecute; } [DebuggerStepThrough] public bool CanExecute(object parameter) { return _canExecute == null ? true : _canExecute(parameter); } public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } public void Execute(object parameter) { _execute(parameter); } }