Delegate Command for WPF 29-12-2015 15:13:50 C# / WPF 0 Bookmark(s) 554 View(s) public class Command : ICommand { private readonly Action _execute; private readonly Predicate _canExecute; public Command(Action execute, Predicate canExecute = null) { _execute = execute; _canExecute = canExecute; } public Command(Action execute, Predicate canExecute = null) { _execute = (o => execute()); _canExecute = canExecute; } public bool CanExecute(object parameter) { if (_canExecute != null) { return _canExecute(parameter); } return true; } public void Execute(object parameter) { _execute(parameter); } public void FireCanExecuteChanged() { CanExecuteChanged.Fire(this); } public event EventHandler CanExecuteChanged; }