Should I check an ICommand's CanExecute method before calling Execute from procedural code?
When using ICommand s in XAML, WPF uses the CanExecute method to enable or disable controls associated with the command. But what if I am calling Execute from procedural code? Should I first check CanExecute to make sure that the command can execute, or should Execute take care of this check for me? In other words, should I do this: if (someCommand.CanExecute(parameter, target)) someCommand.Execute(parameter, target); Or just this: someCommand.Execute(parameter, target); Good style would dictate that you should do the former, check CanExecute first. This will enforce proper decomposition and a