Jak mogę wywołać jeszcze raz CanExecute, tak aby w tym przypadku włączyć/wyłączyć Button za pomocą metody IsEnabled?
A może źle kombinuję, jak można to lepiej rozwiązać?
public class RelayCommand : ICommand
{
private Action _action;
private bool _canExecute;
public RelayCommand(Action action, bool canExecute)
{
_action = action;
_canExecute = canExecute;
}
public void IsEnabled(bool State)
{
this._canExecute = State;
//CommandManager.InvalidateRequerySuggested();
}
public bool CanExecute(object parameter)
{
return _canExecute;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
_action();
}
}