{"record":{"id":"e1e22229ea66120f","repo":"dotnet/wpf","slug":"elementnotenabledexception-repeatbuttonautomationpeer","errorCode":null,"errorMessage":"ElementNotEnabledException","messagePattern":"ElementNotEnabledException","errorType":"exception","errorClass":"ElementNotEnabledException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/RepeatButtonAutomationPeer.cs","lineNumber":44,"sourceCode":"        }\n\n        /// \n        public override object GetPattern(PatternInterface patternInterface)\n        {\n            if (patternInterface == PatternInterface.Invoke)\n            {\n                return this;\n            }\n            else\n            {\n                return base.GetPattern(patternInterface);\n            }\n        }\n\n        void IInvokeProvider.Invoke()\n        {\n            if(!IsEnabled())\n                throw new ElementNotEnabledException();\n\n            RepeatButton owner = (RepeatButton)Owner;\n            owner.AutomationButtonBaseClick();\n        }\n    }\n}\n\n","sourceCodeStart":26,"sourceCodeEnd":52,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/RepeatButtonAutomationPeer.cs#L26-L52","documentation":"RepeatButtonAutomationPeer's IInvokeProvider.Invoke throws ElementNotEnabledException when the RepeatButton is disabled. The UIA Invoke pattern requires the element to be enabled; invoking a disabled button is rejected with this UIA-standard exception.","triggerScenarios":"Calling Invoke() on the Invoke pattern of a RepeatButton with IsEnabled=false.","commonSituations":"Automation tests clicking a disabled button (e.g. during a long-running operation that disables UI); accessibility clients activating a disabled repeat control.","solutions":["Enable the RepeatButton before invoking (owner.IsEnabled = true)","Guard the call with a check of the peer's IsEnabled() / owner IsEnabled","Catch ElementNotEnabledException and retry after the control becomes enabled"],"exampleFix":"// before\n((IInvokeProvider)repeatButtonPeer).Invoke();\n// after\nif (repeatButton.IsEnabled)\n    ((IInvokeProvider)repeatButtonPeer).Invoke();","handlingStrategy":"validation","validationCode":"if (!repeatButton.IsEnabled) { /* enable or abort */ }","typeGuard":"static bool CanInvoke(ButtonBase b) => b?.IsEnabled == true;","tryCatchPattern":"try { invokeProvider.Invoke(); }\ncatch (ElementNotEnabledException) { /* control disabled */ }","preventionTips":["Check IsEnabled before Invoke","Avoid invoking buttons disabled by in-flight operations","Poll for IsEnabled in UI tests","Handle UIA_E_ELEMENTNOTENABLED HRESULT in clients"],"tags":["wpf","ui-automation","disabled-element"],"backgroundTag":"authentication-required","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}