{"record":{"id":"0cf2ae79129c6390","repo":"dotnet/wpf","slug":"ianimatable-cantanimatesealeddo","errorCode":"IAnimatable_CantAnimateSealedDO","errorMessage":"SR.IAnimatable_CantAnimateSealedDO (IAnimatable_CantAnimateSealedDO)","messagePattern":"SR\\.IAnimatable_CantAnimateSealedDO \\(IAnimatable_CantAnimateSealedDO\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Animatable.cs","lineNumber":86,"sourceCode":"            if (!AnimationStorage.IsPropertyAnimatable(this, dp))\n            {\n                throw new ArgumentException(SR.Format(SR.Animation_DependencyPropertyIsNotAnimatable, dp.Name, this.GetType()), nameof(dp));\n            }\n\n            if (clock != null\n                && !AnimationStorage.IsAnimationValid(dp, clock.Timeline))\n            {\n                throw new ArgumentException(SR.Format(SR.Animation_AnimationTimelineTypeMismatch, clock.Timeline.GetType(), dp.Name, dp.PropertyType), nameof(clock));\n            }\n\n            if (!HandoffBehaviorEnum.IsDefined(handoffBehavior))\n            {\n                throw new ArgumentException(SR.Animation_UnrecognizedHandoffBehavior);\n            }\n\n            if (IsSealed)\n            {\n                throw new InvalidOperationException(SR.Format(SR.IAnimatable_CantAnimateSealedDO, dp, this.GetType()));\n            }\n\n            AnimationStorage.ApplyAnimationClock(this, dp, clock, handoffBehavior);\n        }\n\n        /// <summary>\n        /// Starts an animation for a DependencyProperty. The animation will\n        /// begin when the next frame is rendered.\n        /// </summary>\n        /// <param name=\"dp\">\n        /// The DependencyProperty to animate.\n        /// </param>\n        /// <param name=\"animation\">\n        /// <para>The AnimationTimeline to used to animate the property.</para>\n        /// <para>If the AnimationTimeline's BeginTime is null, any current animations\n        /// will be removed and the current value of the property will be held.</para>\n        /// <para>If this value is null, all animations will be removed from the property\n        /// and the property value will revert back to its base value.</para>","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Animatable.cs#L68-L104","documentation":"ApplyAnimationClock was called on a Freezable/Animatable that is currently sealed (frozen). Sealed objects are immutable, so WPF throws an InvalidOperationException — you cannot add animation clocks to them. Animating requires a mutable (unfrozen, unsealed) instance.","triggerScenarios":"Calling ApplyAnimationClock on a frozen brush/pen/geometry (e.g. Brushes.Red, a frozen Freezable obtained from a resource or from FindResource) or on any object whose IsSealed/IsFrozen is true.","commonSituations":"Animating system-provided frozen brushes (Brushes.*, SystemColors.*Brush); sharing a single Freezable across many visuals after calling Freeze(); animating a resource-retrieved brush without cloning.","solutions":["Clone the frozen object first: var clone = frozenBrush.Clone(); then animate the clone and assign it back to the target property.","Use CloneCurrentValue() to preserve current animated values before unfreezing.","Avoid calling Freeze() on objects you intend to animate."],"exampleFix":"// before\nmyRect.Fill.ApplyAnimationClock(SolidColorBrush.ColorProperty, clock); // Fill is frozen Brushes.Red\n// after\nvar brush = ((SolidColorBrush)myRect.Fill).Clone();\nmyRect.Fill = brush;\nbrush.ApplyAnimationClock(SolidColorBrush.ColorProperty, clock);","handlingStrategy":"validation","validationCode":"if (animatable is Freezable f && f.IsFrozen)\n{\n    var clone = f.CloneCurrentValue();\n    targetProperty.SetValue(owner, clone);\n    animatable = clone;\n}","typeGuard":"static bool CanAnimate(DependencyObject o) => o is Freezable f ? !f.IsFrozen : !((Animatable)o).IsSealed;","tryCatchPattern":"try { animatable.ApplyAnimationClock(dp, clock); }\ncatch (InvalidOperationException) { animatable = ((Freezable)animatable).Clone(); /* retry on clone */ }","preventionTips":["Check IsFrozen before animating Freezables.","Never freeze objects you plan to animate.","Clone resources fetched from shared dictionaries before animating them."],"tags":["wpf","animation","freezable","immutable-object"],"backgroundTag":"unsupported-operation","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"}