{"record":{"id":"aac76a1492fc6acc","repo":"dotnet/wpf","slug":"sr-invaliddrawingattributesheight","errorCode":null,"errorMessage":"SR.InvalidDrawingAttributesHeight","messagePattern":"SR\\.InvalidDrawingAttributesHeight","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/DrawingAttributes.cs","lineNumber":161,"sourceCode":"        /// The height of the StylusTip\n        /// </summary>\n        public double Height\n        {\n            get\n            {\n                //prevent boxing / unboxing if possible\n                if (!_extendedProperties.Contains(KnownIds.StylusHeight))\n                {\n                    Debug.Assert(DrawingAttributes.DefaultHeight == (double)GetDefaultDrawingAttributeValue(KnownIds.StylusHeight));\n                    return DrawingAttributes.DefaultHeight;\n                }\n                return (double)GetExtendedPropertyBackedProperty(KnownIds.StylusHeight);\n            }\n            set\n            {\n                if (double.IsNaN(value) || value < MinHeight || value > MaxHeight)\n                {\n                    throw new ArgumentOutOfRangeException(\"Height\", SR.InvalidDrawingAttributesHeight);\n                }\n                //no need to raise change events, they will bubble up from the EPC\n                //underneath us\n                SetExtendedPropertyBackedProperty(KnownIds.StylusHeight, value);\n            }\n        }\n\n        /// <summary>\n        /// The width of the StylusTip\n        /// </summary>\n        public double Width\n        {\n            get\n            {\n                //prevent boxing / unboxing if possible\n                if (!_extendedProperties.Contains(KnownIds.StylusWidth))\n                {\n                    Debug.Assert(DrawingAttributes.DefaultWidth == (double)GetDefaultDrawingAttributeValue(KnownIds.StylusWidth));","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/DrawingAttributes.cs#L143-L179","documentation":"DrawingAttributes.Height setter throws ArgumentOutOfRangeException with SR.InvalidDrawingAttributesHeight when the value is NaN, below MinHeight, or above MaxHeight. Stylus height must be a finite, in-range double because it directly sizes the ink stroke geometry. The valid bounds are exposed as DrawingAttributes.MinHeight/MaxHeight constants.","triggerScenarios":"Assigning double.NaN, a negative number, zero (if below MinHeight), or a value above MaxHeight to DrawingAttributes.Height — often from unparsed user input or computed geometry.","commonSituations":"Binding Height to a slider or text box without range validation; NaN propagating from a division or default-initialized double; copying values from a unit-converted source.","solutions":["Clamp the value: Math.Max(DrawingAttributes.MinHeight, Math.Min(DrawingAttributes.MaxHeight, value)).","Validate with double.IsNaN before assigning and substitute a sensible default (e.g. 1.0).","Constrain the UI input control's Min/Max to DrawingAttributes.MinHeight/MaxHeight."],"exampleFix":"// before\nda.Height = parsedValue; // may be NaN or out of range\n// after\nda.Height = Math.Clamp(parsedValue, DrawingAttributes.MinHeight, DrawingAttributes.MaxHeight);","handlingStrategy":"validation","validationCode":"static bool IsValidHeight(double v) => !double.IsNaN(v) && v >= DrawingAttributes.MinHeight && v <= DrawingAttributes.MaxHeight;","typeGuard":"static bool IsFiniteInRange(double v, double min, double max) => !double.IsNaN(v) && !double.IsInfinity(v) && v >= min && v <= max;","tryCatchPattern":"try { da.Height = value; }\ncatch (ArgumentOutOfRangeException) { da.Height = DrawingAttributes.DefaultHeight; /* or clamp */ }","preventionTips":["Clamp with Math.Clamp(value, DrawingAttributes.MinHeight, DrawingAttributes.MaxHeight)","Check double.IsNaN on any computed or parsed value before assignment","Bound UI inputs (sliders/text boxes) to MinHeight/MaxHeight"],"tags":["wpf","ink","argumentoutofrange","validation"],"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-21T21:30:21.729Z"}