namespace Core { using System; using System.Windows.Input; /// /// TODO: Update summary. /// public sealed class RelayCommand : ICommand { #region Fields private readonly Action execute; private readonly Predicate canExecute; #endregion #region Constructors public RelayCommand(Action execute) : this(execute, null) { } public RelayCommand(Action execute, Predicate canExecute) { if (execute == null) { throw new ArgumentNullException("execute"); } this.execute = execute; this.canExecute = canExecute; } #endregion #region ICommand Members [DebuggerStepThrough] public bool CanExecute(object parameter) { return this.canExecute == null || this.canExecute(parameter); } public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } public void Execute(object parameter) { this.execute(parameter); } #endregion } }