主要是你手动触发事件就行了!~ 改变 CanExecute的返回值,再手动触发 CanExecuteChanged 事件就OK啦!
public class AAACommand : ICommand
{
private bool _isRun;
public bool CanExecute(object parameter)
{
return !_isRun;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
_isRun = true;
if (CanExecuteChanged == null)
{
CanExecuteChanged(this, new EventArgs());
}
// 你的代码
_isRun = false;
if (CanExecuteChanged == null)
{
CanExecuteChanged(this, new EventArgs());
}
}
}