using System; using System.Windows.Input; namespace Life.Misc { public class DelegateCommand : ICommand { public Action Action { get; set; } public Predicate Predicate { get; set; } public bool CanExecute(object parameter) { if (Action == null) return false; return Predicate?.Invoke((T) parameter) ?? true; } public void Execute(object parameter) { Action?.Invoke((T)parameter); } public event EventHandler CanExecuteChanged; } }