You got the idea right. Implement a CanExecute
method that returns the result of your model validation so that when it fails, the button will be disabled.
Then, you must make sure that the CanExecute
is called again when the validation conditions change - for instance, when a binding property has changed. In order to do so, you may require more advanced implementations of ICommand
such as Prism's DelegateCommand
.