{"record":{"id":"edfede609111f703","repo":"dotnet/wpf","slug":"elementnotenabledexception-edfede","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/GridViewColumnHeaderAutomationPeer.cs","lineNumber":53,"sourceCode":"        }\n\n        /// \n        public override object GetPattern(PatternInterface patternInterface)\n        {\n            if (patternInterface == PatternInterface.Invoke || patternInterface == PatternInterface.Transform)\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            GridViewColumnHeader owner = (GridViewColumnHeader)Owner;\n            owner.AutomationClick();\n        }\n\n        #region ITransformProvider\n\n        bool ITransformProvider.CanMove { get { return false; } }\n\n        //Note: CanResize can be false if Max/MinWidth,Height has been added on GridViewColumn/ColumnHeader\n        bool ITransformProvider.CanResize { get { return true; } }\n        bool ITransformProvider.CanRotate { get { return false; } }\n\n        //Note: Don't support Move so far, if users do need this feature to reorder columns, \n        //we can consider to add it later. (One concern is GVCH doesn't support reorder by moving itself)\n        void ITransformProvider.Move(double x, double y)\n        {\n            throw new InvalidOperationException(SR.UIA_OperationCannotBePerformed);","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/GridViewColumnHeaderAutomationPeer.cs#L35-L71","documentation":"GridViewColumnHeaderAutomationPeer's IInvokeProvider.Invoke throws ElementNotEnabledException when IsEnabled() is false, i.e. the GridViewColumnHeader (ListView header) is disabled. UIA requires Invoke to fail with this exception rather than silently no-op on disabled elements.","triggerScenarios":"Invoking the Invoke pattern on a ListView column header while the header or its ListView/ancestor has IsEnabled=false (e.g. during a load state, or header with a disabled template).","commonSituations":"UI tests clicking ListView column headers (to sort) while the ListView is disabled inside a busy overlay; accessibility tools invoking headers on disabled controls.","solutions":["Ensure the GridViewColumnHeader and its ancestors are enabled (IsEnabled=true) before invoking.","Check the element's IsEnabled UIA property before calling Invoke.","Catch ElementNotEnabledException in the automation client and defer the click until the control is enabled.","If header interactivity is unwanted, use a header template that is not a disabled button rather than disabling the control."],"exampleFix":"// before\n((IInvokeProvider)headerPeer).Invoke();\n// after\nif (((AutomationPeer)headerPeer).IsEnabled()) ((IInvokeProvider)headerPeer).Invoke();","handlingStrategy":"validation","validationCode":"if (!peer.IsEnabled()) throw new SkipTestException(\"GridViewColumnHeader disabled\");","typeGuard":null,"tryCatchPattern":"try { ((IInvokeProvider)peer).Invoke(); }\ncatch (ElementNotEnabledException) { /* wait until enabled, then retry */ }","preventionTips":["Verify IsEnabled before Invoke","Avoid disabling ListView while tests run","Wait for busy overlays to clear before header clicks"],"tags":["wpf","ui-automation","listview","disabled-element"],"backgroundTag":"permission-denied","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"}