Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DelegateCommand<T> : ICommand
- {
- private readonly Action<T> execute;
- private readonly Func<T, bool> canExecute;
- public DelegateCommand(Action<T> execute, Func<T, bool> canExecute = null)
- {
- this.execute = execute;
- this.canExecute = canExecute;
- }
- public bool CanExecute(object parameter)
- {
- return this.canExecute == null || this.canExecute((T)parameter);
- }
- public void Execute(object parameter)
- {
- this.execute((T)parameter);
- }
- public event EventHandler CanExecuteChanged;
- }
Advertisement
Add Comment
Please, Sign In to add comment