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) { _action = execute; _canExecute = canExecute; } public bool CanExecute(object parameter) { return _canExecute(); } public event EventHandler CanExecuteChanged; public void Execute(object parameter) { _action((T)parameter); } public void NotifyCanExecuteChanged() { if (CanExecuteChanged != null) { CanExecuteChanged(this, EventArgs.Empty); } } } }