using System; using System.Windows.Input; namespace FSI.Lib.MVVM { /// /// DelegateCommand borrowed from /// http://www.wpftutorial.net/DelegateCommand.html /// public class DelegateCommand : ICommand { private readonly Predicate _canExecute; private readonly Action _execute; public DelegateCommand(Action execute, Predicate canExecute = null) { _execute = execute; _canExecute = canExecute; } public void RaiseCanExecuteChanged() { CanExecuteChanged?.Invoke(this, EventArgs.Empty); } #region ICommand Members public event EventHandler CanExecuteChanged; public bool CanExecute(object parameter) { return _canExecute == null || _canExecute(parameter); } public void Execute(object parameter) { _execute(parameter); } #endregion } }