{"record":{"id":"099badf4005cb3c3","repo":"dotnet/wpf","slug":"argumentoutofrangeexception-parametername-ribbontabspanel","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/RibbonTabsPanel.cs","lineNumber":297,"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\n        #endregion\n    }\n\n    //-----------------------------------------------------------\n    // ScrollData class\n    //-----------------------------------------------------------\n    #region ScrollData\n\n    // Helper class to hold scrolling data.\n    // This class exists to reduce working set when SCP is delegating to another implementation of ISI.\n    // Standard \"extra pointer always for less data sometimes\" cache savings model:\n    internal class ScrollData\n    {","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/Primitives/RibbonTabsPanel.cs#L279-L315","documentation":"RibbonTabsPanel.ValidateInputOffset throws ArgumentOutOfRangeException(parameterName) when the supplied scroll offset is double.NaN, then otherwise clamps negatives to 0. It validates offsets arriving through the panel's IScrollInfo implementation (SetHorizontalOffset/SetVerticalOffset and related scroll methods).","triggerScenarios":"Invoking scroll methods on RibbonTabsPanel with a NaN offset — e.g. SetHorizontalOffset(NaN), SetVerticalOffset(NaN), or internal callers (newValue path) computing a NaN target offset from invalid item/viewport measurements.","commonSituations":"Programmatic scrolling of ribbon tabs, animation or data-driven scroll offsets that yield NaN, or custom navigation logic hitting zero-size measures (0/0).","solutions":["Pass a finite offset; use the panel's current HorizontalOffset/VerticalOffset when the target is unknown.","Validate with double.IsFinite (or !double.IsNaN) before calling and fall back to 0 or the current offset.","Fix the NaN source: avoid dividing by zero extents and initialize measure-dependent values before scrolling."],"exampleFix":"// before\nribbonTabsPanel.SetHorizontalOffset(targetOffset); // targetOffset may be NaN\n// after\nif (!double.IsNaN(targetOffset))\n{\n    ribbonTabsPanel.SetHorizontalOffset(targetOffset);\n}","handlingStrategy":"validation","validationCode":"var safeOffset = double.IsNaN(target) ? ribbonTabsPanel.HorizontalOffset : target;\nribbonTabsPanel.SetHorizontalOffset(safeOffset);","typeGuard":"static bool IsUsableOffset(double d) => !double.IsNaN(d);","tryCatchPattern":"try { panel.SetVerticalOffset(target); }\ncatch (ArgumentOutOfRangeException) { panel.SetVerticalOffset(panel.VerticalOffset); }","preventionTips":["Never feed animated/computed values straight into IScrollInfo offsets.","Guard NaN at the computation source (denominators, uninitialized fields).","Prefer the panel's own offset properties as fallbacks."],"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"}