dotnet/wpf · error · InvalidOperationException
SR.UIA_OperationCannotBePerformed
Error message
SR.UIA_OperationCannotBePerformed
What it means
GridSplitterAutomationPeer explicitly rejects resizing: ITransformProvider.Resize always throws InvalidOperationException(SR.UIA_OperationCannotBePerformed). The peer reports CanResize=false, and UIA convention is to throw this exception if a client still attempts the unsupported operation.
Solutions
- Do not call Resize on GridSplitter; check CanResize first and skip when false.
- Set the splitter's resize behavior via ResizeDirection/ResizeBehavior properties in XAML instead of the UIA Transform pattern.
- Catch InvalidOperationException from Resize and treat as operation-not-supported.
- Use the Grid's ColumnDefinition/RowDefinition manipulation (e.g. GridResizeBehavior) as the supported resizing mechanism.
Example fix
// before ((ITransformProvider)peer).Resize(120, 30); // after if (((ITransformProvider)peer).CanResize) ((ITransformProvider)peer).Resize(120, 30); else splitter.ResizeDirection = GridResizeDirection.Columns;
Defensive patterns
Strategy: validation
Validate before calling
if (!((ITransformProvider)peer).CanResize) throw new NotSupportedException("GridSplitter cannot be resized via Transform pattern"); Try / catch
try { ((ITransformProvider)peer).Resize(w, h); }
catch (InvalidOperationException) { /* unsupported: use XAML resize behavior */ } Prevention
- Always check CanResize before Resize
- Configure GridSplitter via ResizeDirection/ResizeBehavior in XAML
- Skip unsupported pattern methods in generic test drivers
When it happens
Trigger: A UIA client calls ITransformProvider.Resize on a GridSplitter element despite the Transform pattern's CanResize property being false.
Common situations: Generic test drivers that invoke every pattern method without checking capability properties like CanResize; tools recording and replaying transform operations on elements whose capabilities differ.
Related errors
- ArgumentOutOfRangeException
- ElementNotEnabledException
- SR.TextProvider_TextSelectionNotSupported
- SR.UIA_OperationCannotBePerformed
- SR.UIA_OperationCannotBePerformed
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/8add38d760d9d7cb.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/GridSplitterAutomationPeer.cs:52
bool ITransformProvider.CanResize { get { return false; } }
bool ITransformProvider.CanRotate { get { return false; } }
void ITransformProvider.Move(double x, double y)
{
if (!IsEnabled())
throw new ElementNotEnabledException();
if (double.IsInfinity(x) || double.IsNaN(x))
throw new ArgumentOutOfRangeException(nameof(x));
if (double.IsInfinity(y) || double.IsNaN(y))
throw new ArgumentOutOfRangeException(nameof(y));
((GridSplitter)Owner).KeyboardMoveSplitter(x, y);
}
void ITransformProvider.Resize(double width, double height)
{
throw new InvalidOperationException(SR.UIA_OperationCannotBePerformed);
}
void ITransformProvider.Rotate(double degrees)
{
throw new InvalidOperationException(SR.UIA_OperationCannotBePerformed);
}
#endregion
}
}
View on GitHub (pinned to 81131a70a4)