dotnet/wpf · error · ElementNotEnabledException
ElementNotEnabledException
Error message
ElementNotEnabledException
What it means
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.
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.
Example fix
// before
selectionItemPattern.Select();
// after
if (radioButton.Enabled)
{
selectionItemPattern.Select();
}
else
{
// pick an enabled option or enable it in app state first
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!radioButton.IsEnabled) { /* choose another option or enable first */ } Try / catch
try { selectionItemPattern.Select(); } catch (ElementNotEnabledException) { /* disabled option: handle explicitly */ } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Form-filling automation selecting radio options that are disabled by conditional UI logic; tests running against dialogs where some choices are unavailable by design.
Related errors
- ElementNotEnabledException
- SR.UIA_OperationCannotBePerformed
- UIA_E_ELEMENTNOTENABLED
- E_ACCESSDENIED
- E_INVALIDARG
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/63db76a61120fbe7.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/RadioButtonAutomationPeer.cs:52
}
else if(patternInterface == PatternInterface.SynchronizedInput)
{
return base.GetPattern(patternInterface);
}
else
{
return null;
}
}
/// <summary>
/// Sets the current element as the selection
/// This clears the selection from other elements in the container
/// </summary>
void ISelectionItemProvider.Select()
{
if (!IsEnabled())
throw new ElementNotEnabledException();
((RadioButton)Owner).SetCurrentValueInternal(RadioButton.IsCheckedProperty, MS.Internal.KnownBoxes.BooleanBoxes.TrueBox);
}
/// <summary>
/// Adds current element to selection
/// </summary>
void ISelectionItemProvider.AddToSelection()
{
if (((RadioButton)Owner).IsChecked != true)
throw new InvalidOperationException(SR.UIA_OperationCannotBePerformed);
}
/// <summary>
/// Removes current element from selection
/// </summary>View on GitHub (pinned to 81131a70a4)