{"record":{"id":"95232242989705e7","repo":"dotnet/wpf","slug":"sr-animation-invalid-defaultvalue-origin-0-value-2-952322","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/DoubleAnimation.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.IsValidAnimationValueDouble(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.IsValidAnimationValueDouble(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/DoubleAnimation.cs#L295-L331","documentation":"DoubleAnimation.GetCurrentValueCore throws InvalidOperationException when origin validation is requested and the default origin value fails AnimatedTypeHelpers.IsValidAnimationValueDouble. WPF will not interpolate from an invalid double (e.g. NaN/unset base value); the message names the animation type, role (origin) and the value.","triggerScenarios":"defaultOriginValue invalid (commonly double.NaN or an unset property default) while validateOrigin is true and no explicit From value is set on the DoubleAnimation.","commonSituations":"Animating Width/Height/Opacity-like double properties before layout has assigned a value (NaN); relying on the current value as origin without From; sentinel double defaults.","solutions":["Set an explicit From value on the DoubleAnimation","Ensure the animated property has a concrete, valid double value before BeginAnimation (avoid NaN)","Delay animation start until layout assigns the value (e.g. after Loaded)","Animate a different property or use a layout-safe target"],"exampleFix":"// before\nvar anim = new DoubleAnimation(100, TimeSpan.FromSeconds(1)); // From = default (NaN for Width)\n// after\nelement.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); // ensure valid base value\nvar anim = new DoubleAnimation { From = element.ActualWidth, To = 100, Duration = TimeSpan.FromSeconds(1) };","handlingStrategy":"validation","validationCode":"if (double.IsNaN(currentValue) || !AnimatedTypeHelpers.IsValidAnimationValueDouble(currentValue))\n    anim.From = 0; // provide a concrete origin","typeGuard":"static bool IsValidDoubleOrigin(double v) => !double.IsNaN(v) && !double.IsInfinity(v) && AnimatedTypeHelpers.IsValidAnimationValueDouble(v);","tryCatchPattern":"try { target.BeginAnimation(depProp, anim); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"origin\")) { /* set From explicitly and retry */ }","preventionTips":["Set From explicitly when animating layout properties whose current value may be NaN (Width/Height)","Start animations after layout completes (Loaded) so base values are assigned","Check for NaN/Infinity before BeginAnimation"],"tags":["wpf","animation","double","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-22T01:17:13.364Z"}