{
                  
                  
                          readonly Action<object> _execute;
                  
                  
                          readonly Predicate<object> _canExecute;
                  
                  
                  
                  
                  
                          public RelayCommand(Action<object> execute)
                  
                  
                              : this(execute, null)
                  
                  
                          {
                  
                  
                          }
                  
                  
                  
                  
                  
                          public RelayCommand(Action<object> execute, Predicate<object> canExecute = null)
                  
                  
                          {
                  
                  
                              if (execute == null)
                  
                  
                              {
                  
                  
                                  throw new ArgumentNullException("execute");
                  
                  
                              }
                  
                  
                  
                  
                  
                              _execute = execute;
                  
                  
                              _canExecute = canExecute;
                  
                  
                          }
                  
                  
                  
                  
                  
                          public bool CanExecute(object parameter)
                  
                  
                          {
                  
                  
                              return _canExecute == null ? true : _canExecute.Invoke(parameter);
                  
                  
                          }
                  
                  
                  
                  
                  
                          public event EventHandler CanExecuteChanged
                  
                  
                          {
                  
                  
                              add 
                  
                  
                              {
                  
                  
                                  CommandManager.RequerySuggested += value;
                  
                  
                              }
                  
                  
                              remove
                  
                  
                              {
                  
                  
                                  CommandManager.RequerySuggested -= value;
                  
                  
                              }
                  
                  
                          }
                  
                  
                  
                  
                  
                          public void Execute(object parameter)
                  
                  
                          {
                  
                  
                              _execute.Invoke(parameter);
                  
                  
                          }
                  
                  
                      }
                  
                  
                
Ну и. Почему без них
это реализация iСommand у меня вопрос вот можноли обойтись без Action иPredicate
Обсуждают сегодня