{"record":{"id":"ee0a40f2e0094ada","repo":"dotnet/wpf","slug":"sr-rangevaluemin-windowsslider","errorCode":null,"errorMessage":"SR.RangeValueMin","messagePattern":"SR\\.RangeValueMin","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsSlider.cs","lineNumber":280,"sourceCode":"            // adding support for if WindowsStyle has reversed bit set for the slider.\n            if ((this.WindowStyle & NativeMethods.TBS_REVERSED) != 0)\n            {\n                int maxValue = Misc.ProxySendMessageInt(_hwnd, NativeMethods.TBM_GETRANGEMAX, IntPtr.Zero, IntPtr.Zero);\n                value = maxValue - value;\n            }\n            return value;\n        }\n\n        private void SetSliderValue (int val)\n        {\n            // check for the range\n            if (val > Max)\n            {\n                throw new ArgumentOutOfRangeException(\"value\", val, SR.RangeValueMax);\n            }\n            else if (val < Min)\n            {\n                throw new ArgumentOutOfRangeException(\"value\", val, SR.RangeValueMin);\n            }\n\n            Misc.ProxySendMessage(_hwnd, NativeMethods.TBM_SETPOS, new IntPtr(1), new IntPtr(val));\n        }\n\n        private int LineSize\n        {\n            get\n            {\n                return Misc.ProxySendMessageInt(_hwnd, NativeMethods.TBM_GETLINESIZE, IntPtr.Zero, IntPtr.Zero);\n            }\n        }\n\n        private int Min\n        {\n            get\n            {\n                return Misc.ProxySendMessageInt(_hwnd, NativeMethods.TBM_GETRANGEMIN, IntPtr.Zero, IntPtr.Zero);","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsSlider.cs#L262-L298","documentation":"WindowsSlider.SetSliderValue validates the requested slider position against the control's Min/Max range before sending TBM_SETPOS to the underlying Win32 trackbar. An ArgumentOutOfRangeException with SR.RangeValueMin is thrown when the caller requests a value below the slider's minimum. This enforces the IRangeValueProvider contract that SetValue only accepts in-range values.","triggerScenarios":"Calling IRangeValueProvider.SetValue on a slider (UIA ValuePattern/RangeValue pattern backed by WindowsSlider) with a value less than the control's current Minimum.","commonSituations":"Automation scripts computing target positions from hard-coded constants instead of reading RangeValue.Minimum; UI layout changes that raised a slider's minimum; unit tests feeding 0 or -1 to sliders whose Min is higher.","solutions":["Read the slider's IRangeValueProvider.Minimum and clamp the target value into [Minimum, Maximum] before calling SetValue.","Cast the double RangeValue value to int within range, since WindowsSlider.SetValue takes an int trackbar position.","Re-query the element after UI changes; stale cached Min/Max leads to out-of-range requests."],"exampleFix":"// before\nslider.SetValue(-5);\n// after\ndouble min = rangeValuePattern.Current.Minimum;\ndouble v = Math.Max(min, Math.Min(rangeValuePattern.Current.Maximum, desired));\nslider.SetValue((int)v);","handlingStrategy":"validation","validationCode":"var rv = slider.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern;\ndouble min = rv.Current.Minimum, max = rv.Current.Maximum;\nif (desired < min || desired > max) desired = Math.Max(min, Math.Min(max, desired));","typeGuard":"static bool IsInRange(RangeValuePattern rv, double v) => v >= rv.Current.Minimum && v <= rv.Current.Maximum;","tryCatchPattern":"try { slider.SetValue((int)v); }\ncatch (ArgumentOutOfRangeException ex) { /* clamp and retry */ }","preventionTips":["Always read Minimum/Maximum from the pattern rather than hard-coding","Clamp before SetValue","Re-query the element after UI layout changes"],"tags":["argument-out-of-range","uiautomation","slider"],"backgroundTag":"value-out-of-range","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"}