{"record":{"id":"06c56a99603586e3","repo":"dotnet/wpf","slug":"element-is-not-enabled-windowsformslinklabel","errorCode":null,"errorMessage":"Element is not enabled.","messagePattern":"Element is not enabled\\.","errorType":"exception","errorClass":"ElementNotEnabledException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsFormsLinkLabel.cs","lineNumber":110,"sourceCode":"            return true;\n        }\n\n        #endregion ProxySimple Interface\n\n        #region Invoke Pattern\n\n        // Same as clicking on an hyperlink\n        void IInvokeProvider.Invoke()\n        {\n            // Check that button can be clicked.\n            //\n            // This state could change anytime.\n            //\n\n            // Make sure that the control is enabled\n            if (!SafeNativeMethods.IsWindowEnabled(_hwnd))\n            {\n                throw new ElementNotEnabledException();\n            }\n\n            if (!SafeNativeMethods.IsWindowVisible(_hwnd))\n            {\n                throw new InvalidOperationException(SR.OperationCannotBePerformed);\n            }\n\n            Misc.SetFocus(_hwnd);\n\n            NativeMethods.Win32Point pt = new NativeMethods.Win32Point();\n            if (GetClickablePoint(out pt, false))\n            {\n                Misc.MouseClick(pt.x, pt.y);\n            }\n        }\n\n        #endregion Invoke Pattern\n   }","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsFormsLinkLabel.cs#L92-L128","documentation":"WindowsFormsLinkLabel's Invoke pattern first verifies the underlying Win32 control is enabled via IsWindowEnabled; if not, it throws ElementNotEnabledException to comply with the UIA Invoke pattern contract.","triggerScenarios":"Calling Invoke() on a LinkLabel automation element while the control's Enabled property is false (control disabled in code, designer, or because its container is disabled).","commonSituations":"Forms with disabled controls pending validation or prerequisite state; automation scripts running before the form finishes enabling controls; disabled LinkLabels used as visual placeholders.","solutions":["Enable the control before invoking: linkLabel.Enabled = true.","Check the element's IsEnabled property (via AutomationElement) and skip or wait until it is true.","Catch ElementNotEnabledException around Invoke() and retry after enabling.","If the control is disabled because a parent container is disabled, enable the container first."],"exampleFix":"// before\ninvokePattern.Invoke();\n// after\nif (element.Current.IsEnabled)\n{\n    invokePattern.Invoke();\n}\nelse\n{\n    // enable or wait\n}","handlingStrategy":"try-catch","validationCode":"bool canInvoke = element.Current.IsEnabled;\nif (!canInvoke) { /* enable via app state or abort */ }","typeGuard":"static bool IsInvokable(AutomationElement e) => (bool)e.GetCurrentValue(InvokePattern.IsEnabledProperty) && e.TryGetCurrentPattern(InvokePattern.Pattern, out _);","tryCatchPattern":"try { invokePattern.Invoke(); }\ncatch (ElementNotEnabledException) { /* enable control or surface state error */ }","preventionTips":["Check AutomationElement.IsEnabledProperty before Invoke","Wait for the enabling condition rather than invoking immediately","Ensure parent containers are not disabling the control","Design automation flows to include state-assertion steps"],"tags":["uiautomation","winforms","invoke","element-disabled"],"backgroundTag":"element-not-enabled","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"}