{"record":{"id":"45aa1e4505742bcf","repo":"dotnet/wpf","slug":"sr-animation-invalid-defaultvalue-destination-0-value-2","errorCode":null,"errorMessage":"SR.Animation_Invalid_DefaultValue (destination: {0}, value: {2})","messagePattern":"SR\\.Animation_Invalid_DefaultValue \\(destination: (.+?), value: (.+?)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/ColorAnimation.cs","lineNumber":324,"sourceCode":"\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\n\n            if (IsCumulative)\n            {\n                double currentRepeat = (double)(animationClock.CurrentIteration - 1);\n\n                if (currentRepeat > 0.0)\n                {\n                    Color accumulator = AnimatedTypeHelpers.SubtractColor(to, from);\n\n                    accumulated = AnimatedTypeHelpers.ScaleColor(accumulator, currentRepeat);\n                }","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/ColorAnimation.cs#L306-L342","documentation":"ColorAnimation.GetCurrentValueCore throws InvalidOperationException when the animation is asked to validate its destination value and that value is not a valid animation value for the Color type (e.g. it is Color.Empty or otherwise unusable for interpolation). The library throws because animating to/from an invalid color would produce undefined interpolation results. The message names the animation type, the offending role (destination) and the value.","triggerScenarios":"Calling GetCurrentValueCore (directly or via the animation clock) with defaultDestinationValue that fails AnimatedTypeHelpers.IsValidAnimationValueColor while validateDestination is true — typically when the animated dependency property's current value is Color.Empty or unset and no explicit To value is supplied.","commonSituations":"Animating a Brush/Color property whose base value was never initialized (default Color.Empty); using From/To/By defaults where the target property has no valid current color; code that assigns Color.Empty programmatically before the animation starts.","solutions":["Set an explicit To (and/or From) value on the ColorAnimation so it does not rely on the destination default","Initialize the animated property to a concrete Color (e.g. Colors.Transparent) instead of Color.Empty","Ensure the property being animated is actually a Color-typed animation-compatible property","Wrap animation setup so the target property's current value is checked before calling BeginAnimation"],"exampleFix":"// before\nvar anim = new ColorAnimation(); // no To, destination may be Color.Empty\nrect.BeginAnimation(SolidColorBrush.ColorProperty, anim);\n// after\nvar anim = new ColorAnimation(Colors.Red, Colors.Blue, TimeSpan.FromSeconds(1));\nrect.BeginAnimation(SolidColorBrush.ColorProperty, anim);","handlingStrategy":"validation","validationCode":"if (targetBrush.Color == Color.Empty || targetBrush.Color == default)\n    anim.To = anim.To ?? Colors.Transparent; // provide explicit destination\nelse\n    targetBrush.BeginAnimation(SolidColorBrush.ColorProperty, anim);","typeGuard":"static bool HasValidColor(Color c) => c != Color.Empty && AnimatedTypeHelpers.IsValidAnimationValueColor(c);","tryCatchPattern":"try { target.BeginAnimation(SolidColorBrush.ColorProperty, anim); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"destination\")) { /* log and set static value instead */ target.SetValue(SolidColorBrush.ColorProperty, anim.To ?? Colors.Transparent); }","preventionTips":["Always set To (and From when the base value may be unset)","Initialize animated Color properties to a concrete color, never Color.Empty","Check AnimatedTypeHelpers.IsValidAnimationValueColor before animating"],"tags":["wpf","animation","color","invalid-value"],"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"}