{"record":{"id":"3c8f29c39d879598","repo":"dotnet/wpf","slug":"sr-animation-invalid-defaultvalue-origin-0-value-2","errorCode":null,"errorMessage":"SR.Animation_Invalid_DefaultValue (origin: {0}, value: {2})","messagePattern":"SR\\.Animation_Invalid_DefaultValue \\(origin: (.+?), value: (.+?)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/ColorAnimation.cs","lineNumber":313,"sourceCode":"                    if (IsAdditive)\n                    {\n                        foundation = defaultOriginValue;\n                        validateOrigin = true;\n                    }\n\n                    break;\n\n                default:\n\n                    Debug.Fail(\"Unknown animation type.\");\n\n                    break;\n            }\n\n            if (validateOrigin \n                && !AnimatedTypeHelpers.IsValidAnimationValueColor(defaultOriginValue))\n            {\n                throw new InvalidOperationException(\n                    SR.Format(\n                        SR.Animation_Invalid_DefaultValue,\n                        this.GetType(),\n                        \"origin\",\n                        defaultOriginValue.ToString(CultureInfo.InvariantCulture)));\n            }\n\n            if (validateDestination \n                && !AnimatedTypeHelpers.IsValidAnimationValueColor(defaultDestinationValue))\n            {\n                throw new InvalidOperationException(\n                    SR.Format(\n                        SR.Animation_Invalid_DefaultValue,\n                        this.GetType(),\n                        \"destination\",\n                        defaultDestinationValue.ToString(CultureInfo.InvariantCulture)));\n            }\n","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/ColorAnimation.cs#L295-L331","documentation":"ColorAnimation.GetCurrentValueCore throws InvalidOperationException (SR.Animation_Invalid_DefaultValue) when validateOrigin is true and the provided defaultOriginValue is not a valid Color animation value (AnimatedTypeHelpers.IsValidAnimationValueColor fails). WPF requires a valid origin Color when the animation has no From value to fall back on. The message identifies the animation type, the \"origin\" slot, and the offending value.","triggerScenarios":"Calling GetCurrentValue/GetCurrentValueCore with a null/invalid defaultOriginValue while the ColorAnimation has no From set and no base value exists to serve as origin.","commonSituations":"Animating a Brush/Color property that has never been assigned a base color, or manually invoking the animation evaluation API with a null origin value.","solutions":["Set the From property (e.g. new ColorAnimation { From = Colors.Red, To = Colors.Blue })","Pass a valid Color defaultOriginValue when calling GetCurrentValueCore","Ensure the animated property has a valid base Color before the animation begins"],"exampleFix":"// before\nvar anim = new ColorAnimation { To = Colors.Blue }; // no origin\n// after\nvar anim = new ColorAnimation { From = Colors.Red, To = Colors.Blue };","handlingStrategy":"validation","validationCode":"if (anim.From is null && (defaultOriginValue is null || !IsValidColor(defaultOriginValue)))\n    anim.From = Colors.Transparent; // supply explicit origin before evaluating","typeGuard":"static bool HasValidOrigin(ColorAnimation a) => a.From.HasValue;","tryCatchPattern":"try { value = anim.GetCurrentValue(baseValue, null, clock, defaultClock); }\ncatch (InvalidOperationException) { /* invalid origin: set From or a base Color on the target property */ }","preventionTips":["Set From on ColorAnimation or ensure the animated brush/color property has a base value","Initialize Color/Brush properties before starting the animation","Pass a valid Color when calling GetCurrentValueCore manually"],"tags":["wpf","animation","invalid-operation","color-animation"],"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"}