두 ICommand 개체는 모두 ViewModel에 바인딩됩니다.ViewModel에서 새 ICommand 개체 만들기
첫 번째 방법이 자주 사용되는 것 같습니다.
그러나 두 번째 코드는 일부 코드 줄을 저장하지만 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); }
}
당신이 제안한 것처럼 나는 그 접근법을 피하는 것이 좋기 때문에 - ?? – msfanboy