我认为对此有一个具体的答案。
如果我有一个命令绑定
private bool CanExecute(Object args){
// Should this just be null checks?
// Should it also contain logic?
// example:
return this.SelectedObject != null;
// or
return this.SelectedObject != null && this.SelectedObject.Status == 1;
}
private void Executed(Object args){
//Or should logic be reserved for the Executed command
if(this.SelectedObject.Status == 1)
//Do stuff
else
//Don't do stuff
}
如果我们在执行的方法中进行额外的数据验证,那么拥有一个可以执行的方法似乎是多余的。