{"record":{"id":"4ac18ffcd52ffe29","repo":"dotnet/wpf","slug":"sr-animation-keyspline-invalidvalue-controlpoint1-4ac18f","errorCode":null,"errorMessage":"SR.Animation_KeySpline_InvalidValue (ControlPoint1)","messagePattern":"SR\\.Animation_KeySpline_InvalidValue \\(ControlPoint1\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySpline.cs","lineNumber":167,"sourceCode":"        /// \n        /// </summary>\n        public Point ControlPoint1\n        {\n            get\n            {\n                ReadPreamble();\n\n                return _controlPoint1;\n            }\n            set\n            {\n                WritePreamble();\n\n                if (value != _controlPoint1)\n                {\n                    if (!IsValidControlPoint(value))\n                    {\n                        throw new ArgumentException(SR.Format(\n                            SR.Animation_KeySpline_InvalidValue,\n                            \"ControlPoint1\",\n                            value));\n                    }\n\n                    _controlPoint1 = value;\n\n                    WritePostscript();\n                }\n            }\n        }\n\n        /// <summary>\n        /// \n        /// </summary>\n        public Point ControlPoint2\n        {\n            get","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySpline.cs#L149-L185","documentation":"The KeySpline.ControlPoint1 property setter throws ArgumentException (SR.Animation_KeySpline_InvalidValue) when assigning a point whose X or Y is outside the required [0,1] range. The setter only validates when the new value differs from the current one, but any genuinely out-of-range assignment fails.","triggerScenarios":"keySpline.ControlPoint1 = new Point(x, y) where x < 0, x > 1, y < 0 or y > 1; also storyboard/key-frame code paths that assign control points computed at runtime.","commonSituations":"Animating spline control points driven by sliders or parsed input without range constraints; config systems storing 0-100 percent values; cumulative arithmetic drift pushing coordinates slightly above 1.","solutions":["Clamp the point before assignment: new Point(Math.Clamp(x,0,1), Math.Clamp(y,0,1)).","Constrain UI inputs (sliders min=0 max=1) or normalize parsed values by dividing by their max.","Wrap the setter in try/catch (ArgumentException) and keep/restore the previous control point.","If the spline is replaceable, construct a new KeySpline with validated points instead of mutating."],"exampleFix":"// before\nspline.ControlPoint1 = new Point(userX, userY);\n// after\nspline.ControlPoint1 = new Point(Math.Clamp(userX, 0, 1), Math.Clamp(userY, 0, 1));","handlingStrategy":"validation","validationCode":"if (value.X < 0 || value.X > 1 || value.Y < 0 || value.Y > 1)\n    value = new Point(Math.Clamp(value.X, 0, 1), Math.Clamp(value.Y, 0, 1));\nspline.ControlPoint1 = value;","typeGuard":"static Point SafeControlPoint1(Point p) => new Point(Math.Clamp(p.X, 0.0, 1.0), Math.Clamp(p.Y, 0.0, 1.0));","tryCatchPattern":"Point previous = spline.ControlPoint1;\ntry { spline.ControlPoint1 = candidate; }\ncatch (ArgumentException) { spline.ControlPoint1 = previous; }","preventionTips":["Bind spline editors to sliders with Minimum=0, Maximum=1","Clamp computed/animated control points before assignment","Validate values parsed from XAML/config for range, not just type","Never assign raw external easing data without normalization"],"tags":["wpf","animation","keyspline","property-validation"],"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"}