{"record":{"id":"6c763770f4290b64","repo":"dotnet/wpf","slug":"argumentoutofrangeexception-parametername","errorCode":null,"errorMessage":"ArgumentOutOfRangeException(parameterName)","messagePattern":"ArgumentOutOfRangeException\\(parameterName\\)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/Primitives/RibbonTabHeadersPanel.cs","lineNumber":1045,"sourceCode":"        {\n            get { return 0.0; }\n        }\n\n        private ScrollData ScrollData\n        {\n            get\n            {\n                return _scrollData ?? (_scrollData = new ScrollData());\n            }\n        }\n\n        private ScrollData _scrollData;\n\n        internal static double ValidateInputOffset(double offset, string parameterName)\n        {\n            if (double.IsNaN(offset))\n            {\n                throw new ArgumentOutOfRangeException(parameterName);\n            }\n\n            return Math.Max(0.0, offset);\n        }\n        #endregion\n    }\n}\n","sourceCodeStart":1027,"sourceCodeEnd":1053,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/Primitives/RibbonTabHeadersPanel.cs#L1027-L1053","documentation":"RibbonTabHeadersPanel.ValidateInputOffset rejects NaN offsets with ArgumentOutOfRangeException, naming the offending parameter. It is the panel's shared validation used by IScrollInfo members (SetHorizontalOffset, SetVerticalOffset, LineUp/Down, MakeVisible paths) that accept an offset double.","triggerScenarios":"Calling IScrollInfo methods on RibbonTabHeadersPanel (e.g. SetHorizontalOffset(double.NaN), SetVerticalOffset(NaN)) or internal scroll logic passing NaN — often from uninitialized scroll data or division by zero producing NaN.","commonSituations":"Custom scrolling/keyboard-navigation code driving the ribbon tab headers panel, or binding scroll offsets to computed values that evaluate to NaN (0/0, NaN propagation from transforms).","solutions":["Never pass double.NaN; pass a finite value (e.g. HorizontalOffset or 0).","Check double.IsNaN(offset) at the call site and clamp to the panel's current offset.","Fix the upstream computation producing NaN (guard divisions, initialize scroll extents)."],"exampleFix":"// before\nscrollInfo.SetHorizontalOffset(double.NaN);\n// after\nvar offset = double.IsNaN(computed) ? scrollInfo.HorizontalOffset : computed;\nscrollInfo.SetHorizontalOffset(offset);","handlingStrategy":"validation","validationCode":"if (double.IsNaN(offset)) offset = ribbonTabHeadersPanel.HorizontalOffset;\nribbonTabHeadersPanel.SetHorizontalOffset(offset);","typeGuard":"static bool IsValidOffset(double d) => !double.IsNaN(d) && !double.IsInfinity(d);","tryCatchPattern":"try { panel.SetHorizontalOffset(offset); }\ncatch (ArgumentOutOfRangeException) { panel.SetHorizontalOffset(0); }","preventionTips":["Clamp all scroll offsets with double.IsFinite checks.","Initialize scroll-dependent values before first scroll calls.","Avoid dividing by zero viewport/extents that produce NaN."],"tags":["wpf","ribbon","scrolling","argumentoutofrange"],"backgroundTag":"argument-out-of-range","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}