using System; using System.Windows.Input; namespace WpfTreeView { /// /// A basic command that runs an Action /// public class RelayCommand : ICommand { #region Private Members /// /// The action to run /// private Action mAction; #endregion #region Public Events /// /// The event thats fired when the value has changed /// public event EventHandler CanExecuteChanged = (sender, e) => { }; #endregion #region Constructor /// /// Default constructor /// public RelayCommand(Action action) { mAction = action; } #endregion #region Command Methods /// /// A relay command can always execute /// /// /// public bool CanExecute(object parameter) { return true; } /// /// Executes the commands Action /// /// public void Execute(object parameter) { mAction(); } #endregion } }