My preference is to use the ICommand
interface where possible rather than a class that implements the interface. The technique results in more loosely coupled code. Something like this.
private ICommand cancelCommand;
public ICommand CancelCommand
{
get
{
return cancelCommand ?? (cancelCommand = new RelayCommand(MyCancelMethod));
}
}
By using the null-coalescing operator there is no need for a 'setter' and the
RelayCommand
is instantiated where it is used rather than in a constructor.