{"record":{"id":"3fd83aaef85861d5","repo":"dotnet/wpf","slug":"resizeparametersnotvalid","errorCode":null,"errorMessage":"ResizeParametersNotValid","messagePattern":"ResizeParametersNotValid","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonMenuButtonAutomationPeer.cs","lineNumber":249,"sourceCode":"            get { return false; }\n        }\n\n        void ITransformProvider.Move(double x, double y)\n        {\n            throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);\n        }\n\n        void ITransformProvider.Resize(double width, double height)\n        {\n            if (!IsEnabled())\n                throw new ElementNotEnabledException();\n\n            if (!((ITransformProvider)this).CanResize || width <= 0 || height <= 0)\n                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);\n\n            if (!OwningMenuButton.ResizePopupInternal(width, height))\n            {\n                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.ResizeParametersNotValid);\n            }\n        }\n\n        void ITransformProvider.Rotate(double degrees)\n        {\n            throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);\n        }\n\n        #endregion\n\n        #region Internal methods\n\n        [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]\n        internal void RaiseExpandCollapseAutomationEvent(bool oldValue, bool newValue)\n        {\n            RaisePropertyChangedEvent(\n                ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty,\n                oldValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed,","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonMenuButtonAutomationPeer.cs#L231-L267","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ntransformPattern.Resize(1, 1); // ResizePopupInternal fails -> ResizeParametersNotValid\n// after\nvar current = element.CurrentBoundingRectangle;\ndouble w = Math.Max(current.Width, 100);\ndouble h = Math.Max(current.Height, 50);\ntry { transformPattern.Resize(w, h); }\ncatch (InvalidOperationException)\n{\n    // fall back to default popup size\n}","handlingStrategy":"try-catch","validationCode":"var bounds = element.CurrentBoundingRectangle;\ndouble w = Math.Max(width,  bounds.Width  * 0.5); // stay near a size the popup can honor\ndouble h = Math.Max(height, bounds.Height * 0.5);","typeGuard":null,"tryCatchPattern":"try { transformPattern.Resize(width, height); }\ncatch (InvalidOperationException) when (/* ResizeParametersNotValid */ true)\n{\n    // popup cannot honor these dimensions; fall back to current size\n}","preventionTips":["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."],"tags":["wpf","ribbon","ui-automation","resize"],"backgroundTag":"invalid-argument-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}