两个 ICommand 对象都绑定到一个 ViewModel。
第一种方法似乎经常使用。
但是第二个节省了一些代码行,但是它不会在刷新 Binding 时每次都创建一个新的 ICommand 对象,所以它浪费资源?!
private LightCommand _deleteDocumentCommand;
public LightCommand DeleteDocumentCommand
{
get { return _deleteDocumentCommand ?? (_deleteDocumentCommand = new LightCommand(() => DeleteDocument(), () => CanDeleteDocument)); }
}
public LightCommand DeleteDocumentCommand
{
get { return new LightCommand(() => DeleteDocument(), () => CanDeleteDocument); }
}