I have written a CanExecute method for the DelegateCommand. CanExecute is not being re-evaluated as other commands which inherites from a CommandBase, that looks like this.
public abstract class CommandBase : ICommand
{
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void RaiseCanExecuteChanged()
{
CommandManager.InvalidateRequerySuggested();
}
public virtual bool CanExecute(object paramete开发者_JAVA技巧r)
{
return true;
}
public abstract void Execute(object parameter);
}
Can I make the Prism DelegateCommand work like this, so CanExecute is automatically re-evaluated when appropriate or should I manually call RaiseCanExecuteChanged() when needed?
How should the command or the command manager know that it's execution state changed? To have them know about that you need to signal this via the RaiseCanExecuteChanged method.
精彩评论