It depends on which style you prefer. Most people do not like to have a bunch of logic in properties if they can avoid it.
Personally, I prefer to have a real method to call instead of an anonymous method. My ViewModels look something like this.
public class MyViewModel : ViewModelBase { public RelayCommand<CommandParam> MyCommand { get; private get; } public MyViewModel() { CreateCommands(); } private void CreateCommands() { MyCommand = new RelayCommand<CommandParam>(MyCommandExecute); } private void MyCommandExecute(CommandParam parm) {
Note: if you do not use the enable command, you do not need to invoke the ctor overload, which sets this.
source share