Using commands is handy because WPF automatically disables the source of the command (typically a button) when the command can't be executed.
Evidently, this feature is not available to controls that are not a command source e.g. ListBox.
What is the best way to enable this feature for non command source controls. I thought of a couple of solution:
- Wrap the ListBox with a Button and change the control template of the button so that there is no chrome.
- Create an invisible button and bind the IsEnabled property of the ListBox to the IsEnabled property of the button
- Create a descendant of ListBox that implement ICommandSource.
Is there a more elegant way?