WPF/Prism/MVVM Button/DelegateCommand binding with user-defined button disable logic?

369 views Asked by At

What I want to do is bind a SaveCommand DelegateCommand to a button, but instead of having the CanExecute() == false disable the button, I'd prefer the button be clickable but just run field validation and display a message box if fields are invalid.

I'm using MVVM and would like to achieve this without doing something hackity.

1

There are 1 answers

1
Panh On BEST ANSWER

Why not just have your Execute method of the command do as you state and only use the CanExecute to enable/disable the button? If you don't need to ever disable the button, then only use the Execute portion...