using System; using System.Windows.Input; namespace Juick.Classes { public class DelegateCommand : ICommand { readonly Action action; readonly Func canExecute; public DelegateCommand(Action execute, Func canExecute) { this.action = execute; this.canExecute = canExecute; } public bool CanExecute(object parameter) { return canExecute(); } public event EventHandler CanExecuteChanged; public void Execute(object parameter) { action(parameter); } public void NotifyCanExecuteChanged() { if (CanExecuteChanged != null) { CanExecuteChanged(this, EventArgs.Empty); } } } }