dotnet/wpf · error · InvalidOperationException
ResizeParametersNotValid
Error message
ResizeParametersNotValid
What it means
RibbonMenuButtonAutomationPeer.ITransformProvider.Resize throws InvalidOperationException(SR.ResizeParametersNotValid) when the sizes pass the initial checks (positive, resizable, enabled) but the owner's ResizePopupInternal(width, height) returns false — the requested dimensions cannot produce a valid popup layout for the RibbonMenuButton. The resize request is therefore rejected as infeasible.
Solutions
- Resize within the popup's valid range: read the current popup size and adjust incrementally instead of forcing arbitrary extents.
- Query OwningMenuButton's popup min/max constraints (or probe with small increments) before committing the final size.
- Catch InvalidOperationException(ResizeParametersNotValid) and retry with a reduced/clamped size.
- Fall back to leaving the popup at its default size and verify contents via automation instead of resizing.
Example fix
// before
transformPattern.Resize(1, 1); // ResizePopupInternal fails -> ResizeParametersNotValid
// after
var current = element.CurrentBoundingRectangle;
double w = Math.Max(current.Width, 100);
double h = Math.Max(current.Height, 50);
try { transformPattern.Resize(w, h); }
catch (InvalidOperationException)
{
// fall back to default popup size
} Defensive patterns
Strategy: try-catch
Validate before calling
var bounds = element.CurrentBoundingRectangle; double w = Math.Max(width, bounds.Width * 0.5); // stay near a size the popup can honor double h = Math.Max(height, bounds.Height * 0.5);
Try / catch
try { transformPattern.Resize(width, height); }
catch (InvalidOperationException) when (/* ResizeParametersNotValid */ true)
{
// popup cannot honor these dimensions; fall back to current size
} Prevention
- Resize incrementally from the current popup size rather than to absolute extremes.
- Clamp requested sizes to the popup's minimum content and work-area maximum.
- Retry with reduced dimensions when a resize is rejected.
- Verify resize results against the new bounding rectangle instead of assuming success.
When it happens
Trigger: Calling Resize with dimensions outside what the menu button's popup layout can honor — e.g. smaller than the minimum content size of the dropdown, larger than screen/work-area constraints, or a shape (extreme aspect ratio) the popup layout logic rejects, making ResizePopupInternal fail.
Common situations: UIA test suites that resize to arbitrary values (e.g. 1x1 or fullscreen) and hit the popup's layout limits; DPI scaling changes making previously valid sizes invalid; recorded resize gestures replayed at different resolutions.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Microsoft.Windows.Controls.SR.ResizeParametersNotValid
- SetFocusFailed
- UIA_OperationCannotBePerformed
- ArgumentOutOfRangeException
- ArgumentOutOfRangeException(parameterName)
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/3fd83aaef85861d5.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonMenuButtonAutomationPeer.cs:249
get { return false; }
}
void ITransformProvider.Move(double x, double y)
{
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
}
void ITransformProvider.Resize(double width, double height)
{
if (!IsEnabled())
throw new ElementNotEnabledException();
if (!((ITransformProvider)this).CanResize || width <= 0 || height <= 0)
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
if (!OwningMenuButton.ResizePopupInternal(width, height))
{
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.ResizeParametersNotValid);
}
}
void ITransformProvider.Rotate(double degrees)
{
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
}
#endregion
#region Internal methods
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
internal void RaiseExpandCollapseAutomationEvent(bool oldValue, bool newValue)
{
RaisePropertyChangedEvent(
ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty,
oldValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed,View on GitHub (pinned to 81131a70a4)