When I disable a control in WPF, like say a menu item like
MenuItem aMenuItem = ...
aMenuItem.IsEnabled = false;
the text in the MenuItem is still active, that is it is not grayed out as you would expect when items are disabled.
Is there a simple way to do this not only for Menu items but for any WPF control?
yes by using commands. MenuItems and Buttons have a command property. a Command is an implementation of the ICommand interface which has a method called CanExecute. When can execute is called if it returns true the menutitem or button is enabled, otherwise it is greyed out.
MSDN Command overview
nice simple tutorial on setting up commands
google search :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With