ElementNotEnabledException when checking button's IsEnabled property

Jun 16, 2011 at 6:13 PM
Edited Jun 17, 2011 at 3:12 PM

Update: Sorry I forgot to mention that this only happens when IsEnabled value of Button is false.

I have the following CustomCommand for button. The problem is that when I try to get the value of IsEnabled, I get "System.Windows.Automation.ElementNotEnabledException : The operation is not allowed on a nonenabled element.". What may be the issue?

 

 

    [DataContract]
    public class ButtonValues
    {
        [DataMember] private readonly bool _isEnabled;

        public ButtonValues(bool isEnabled)
        {
            _isEnabled = isEnabled;
        }

        public bool IsEnabled
        {
            get { return _isEnabled; }
        }
    }