{"record":{"id":"63db76a61120fbe7","repo":"dotnet/wpf","slug":"elementnotenabledexception-radiobuttonautomationpeer","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/RadioButtonAutomationPeer.cs","lineNumber":52,"sourceCode":"            }\n            else if(patternInterface == PatternInterface.SynchronizedInput)\n            {\n                return base.GetPattern(patternInterface);\n            }\n            else\n            {\n                return null;\n            }\n        }\n\n        /// <summary>\n        /// Sets the current element as the selection\n        /// This clears the selection from other elements in the container\n        /// </summary>\n        void ISelectionItemProvider.Select()\n        {\n            if (!IsEnabled())\n                throw new ElementNotEnabledException();\n\n            ((RadioButton)Owner).SetCurrentValueInternal(RadioButton.IsCheckedProperty, MS.Internal.KnownBoxes.BooleanBoxes.TrueBox);\n        }\n\n\n        /// <summary>\n        /// Adds current element to selection\n        /// </summary>\n        void ISelectionItemProvider.AddToSelection()\n        {\n            if (((RadioButton)Owner).IsChecked != true)\n                throw new InvalidOperationException(SR.UIA_OperationCannotBePerformed);\n        }\n\n\n        /// <summary>\n        /// Removes current element from selection\n        /// </summary>","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/RadioButtonAutomationPeer.cs#L34-L70","documentation":"ISelectionItemProvider.Select() on RadioButtonAutomationPeer throws ElementNotEnabledException when the owner RadioButton is disabled (IsEnabled() is false). The SelectionItem pattern requires the element to be enabled before it can be programmatically selected.","triggerScenarios":"A UIA client calls SelectionItemPattern.Select() on a disabled RadioButton, e.g. an option greyed out because another mutually exclusive option is active or a dependency isn't satisfied.","commonSituations":"Form-filling automation selecting radio options that are disabled by conditional UI logic; tests running against dialogs where some choices are unavailable by design.","solutions":["Enable the RadioButton first by fixing the application condition that disables it, then Select.","Check IsEnabled/SelectionItemPattern availability in the client before calling Select; choose an enabled alternative.","Catch ElementNotEnabledException and surface which radio option was disabled in the test report."],"exampleFix":"// before\nselectionItemPattern.Select();\n// after\nif (radioButton.Enabled)\n{\n    selectionItemPattern.Select();\n}\nelse\n{\n    // pick an enabled option or enable it in app state first\n}","handlingStrategy":"try-catch","validationCode":"if (!radioButton.IsEnabled) { /* choose another option or enable first */ }","typeGuard":null,"tryCatchPattern":"try { selectionItemPattern.Select(); } catch (ElementNotEnabledException) { /* disabled option: handle explicitly */ }","preventionTips":["Check element IsEnabled before Select in UIA clients","Account for conditional disabling of radio groups in test data","Enable options via the app's state, not by bypassing the UI"],"tags":["wpf","uiautomation","radiobutton","disabled-element"],"backgroundTag":"feature-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"}