dotnet/wpf · error · InvalidOperationException
SR.DoesNotSupportMultipleSelection
Error message
SR.DoesNotSupportMultipleSelection
What it means
WindowsTab's ISelectionItemProvider.Select throws InvalidOperationException with resource SR.DoesNotSupportMultipleSelection when code reaches a branch that permits multi-selection but the tab control only allows a single selection. The UIA Selection pattern contract requires the provider to reject a Select call that would create multiple selections on a control that does not support it. The proxy enforces the single-selection invariant of the Win32 tab control.
Solutions
- Do not call Select on a second tab while another is selected; call Select only on the desired tab item - the single-select control deselects the rest
- Check SelectionPattern.CanSelectMultiple on the parent tab before issuing multi-select-style calls
- Catch InvalidOperationException and treat it as 'operation unsupported for this control'
- Recreate the automation sequence to model single selection instead of additive selection
Example fix
// before
foreach (var tab in tabItems) tab.Select(); // additive multi-select
// after
foreach (var tab in tabItems) { if (!tab.Current.IsSelected) tab.Select(); } // ensures single selection Defensive patterns
Strategy: validation
Validate before calling
bool canAdditiveSelect = selectionPattern.Current.CanSelectMultiple; if (!canAdditiveSelect) throw new SkipSelectionException();
Type guard
bool IsMultiSelectable(AutomationElement el) => el.TryGetCurrentPattern(SelectionPattern.Pattern, out var p) && ((SelectionPattern)p).Current.CanSelectMultiple;
Prevention
- Check SelectionPattern.CanSelectMultiple before multi-select-style calls
- Treat tab items as single-select by default
- Catch InvalidOperationException as unsupported-op signal
When it happens
Trigger: Calling UIA SelectionItemPattern.Select() on a tab item of a Win32 tab control whose code path enters the multi-selection branch while the control allows only one selected item (e.g. TCS_MULTISELECT-style handling where only single selection is actually permitted).
Common situations: Automation scripts selecting tab items on classic Win32 tab controls; apps whose tab style changed between frameworks; UIA clients assuming Excel-like multi-select tabs.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/72f0bb3b87473bf7.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsTab.cs:1113
// If multiple selections allowed, add requested selection
if (WindowsTab.SupportMultipleSelection(_hwnd))
{
// Press ctrl and mouse click tab
NativeMethods.Win32Point pt = new NativeMethods.Win32Point();
if (GetClickablePoint(out pt, true))
{
Input.SendKeyboardInput(Key.LeftCtrl, true);
Misc.MouseClick(pt.x, pt.y);
Input.SendKeyboardInput(Key.LeftCtrl, false);
return;
}
throw new InvalidOperationException(SR.OperationCannotBePerformed);
}
// else only single selection allowed
else
{
throw new InvalidOperationException(SR.DoesNotSupportMultipleSelection);
}
}
// Removes this element from the selection
void ISelectionItemProvider.RemoveFromSelection()
{
// Make sure that the control is enabled
if (!SafeNativeMethods.IsWindowEnabled(_hwnd))
{
throw new ElementNotEnabledException();
}
// If not selected, done
if (!((ISelectionItemProvider)this).IsSelected)
{
return;
}
View on GitHub (pinned to 81131a70a4)