{"record":{"id":"50f5e115da436eb6","repo":"dotnet/wpf","slug":"microsoft-windows-controls-sr-resizeparametersnotvalid","errorCode":null,"errorMessage":"Microsoft.Windows.Controls.SR.ResizeParametersNotValid","messagePattern":"Microsoft\\.Windows\\.Controls\\.SR\\.ResizeParametersNotValid","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonMenuItemDataAutomationPeer.cs","lineNumber":353,"sourceCode":"\n            UIElement owner = GetWrapper();\n            if (owner == null)\n            {\n                throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.VirtualizedElement);\n            }\n\n            RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;\n            if (menuItemOwner == null)\n            {\n                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);\n            }\n\n            if (!((ITransformProvider)this).CanResize || width <= 0 || height <= 0)\n                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);\n\n            if (!menuItemOwner.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#if !RIBBON_IN_FRAMEWORK\n        #region Private methods\n\n        private UIElement GetWrapper()\n        {\n            UIElement wrapper = null;\n            ItemsControlAutomationPeer itemsControlAutomationPeer = ItemsControlAutomationPeer;\n            if (itemsControlAutomationPeer != null)","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonMenuItemDataAutomationPeer.cs#L335-L371","documentation":"Resize throws InvalidOperationException(SR.ResizeParametersNotValid) when RibbonMenuItem.ResizePopupInternal(width, height) returns false — i.e. the passed dimensions were rejected by the menu item's internal popup sizing logic even though CanResize was true and dimensions were positive. It signals the resize could not be applied to the popup.","triggerScenarios":"TransformPattern.Resize(w,h) on a valid, checkable RibbonMenuItem where ResizePopupInternal fails — e.g. dimensions incompatible with the popup's layout constraints, popup not open, or sizes exceeding/falling below internal min/max popup bounds.","commonSituations":"UIA tests probing extreme popup sizes; resizing while the submenu popup is closing; gallery/dropdown popups whose layout cannot honor the requested size.","solutions":["Pass dimensions within the popup's realistic min/max size range (measure the popup's constraints first)","Ensure the submenu popup is fully open before resizing","Catch InvalidOperationException and retry with the popup's current size as a baseline","Fall back to resizing via the RibbonMenu's own layout properties instead of UIA"],"exampleFix":"// before\ntransformPattern.Resize(1, 1); // likely rejected by ResizePopupInternal\n// after\nvar target = new Size(Math.Max(minWidth, w), Math.Max(minHeight, h));\nif (transformPattern.Current.CanResize)\n{\n    transformPattern.Resize(target.Width, target.Height);\n}","handlingStrategy":"try-catch","validationCode":"bool sizeOk = width > 0 && height > 0 && width <= menuItem.MaxPopupWidth && height <= menuItem.MaxPopupHeight; // within popup constraints","typeGuard":"bool IsWithinPopupBounds(double w, double h) => w > 0 && h > 0 && w <= popup.MaxWidth && h <= popup.MaxHeight;","tryCatchPattern":"try { transformPattern.Resize(w, h); } catch (InvalidOperationException) { var s = currentPopupSize; transformPattern.Resize(s.Width, s.Height + delta); }","preventionTips":["Stay within the popup's min/max layout constraints","Resize only while the submenu popup is fully open","Start from the popup's current size and adjust incrementally"],"tags":["wpf","ui-automation","resize","popup"],"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"}