【发布时间】:2012-05-05 20:38:24
【问题描述】:
视图上有不同的按钮,当一个命令被执行时,我如何控制按钮的 IsEnabled 状态?
如果我执行这个命令:
public ICommand DoSomethingCommand
{
get
{
if (doSomethingCommand == null)
{
doSomethingCommand = new RelayCommand(
(parameter) =>
{
this.IsBusy = true;
this.someService.DoSomething(
(b, m) =>
{
this.IsBusy = false;
}
);
},
(parameter) => !this.IsBusy);
}
return this.doSomethingCommand ;
}
}
我设置了触发 OnPropertyChanged 事件的 IsBusy 属性。所有其他按钮在其命令的 CanExecute 中检查此属性。但是执行上述命令时,按钮不会被禁用。
我该怎么做?
【问题讨论】: