{"record":{"id":"d6e31482e1e75340","repo":"dotnet/wpf","slug":"sr-format-sr-ianimatable-cantanimatesealeddo-dp-this-gettype-d6e314","errorCode":null,"errorMessage":"SR.Format(SR.IAnimatable_CantAnimateSealedDO, dp, this.GetType())","messagePattern":"SR\\.Format\\(SR\\.IAnimatable_CantAnimateSealedDO, dp, this\\.GetType\\(\\)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Generated/UIElement.cs","lineNumber":87,"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":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Generated/UIElement.cs#L69-L105","documentation":"UIElement.ApplyAnimationClock throws InvalidOperationException(SR.IAnimatable_CantAnimateSealedDO, formatted with the DP and element type) when IsSealed is true. A sealed (frozen/immutable) DependencyObject cannot have its animation state modified, so the library refuses the operation.","triggerScenarios":"Calling ApplyAnimationClock on a freezable element (e.g. a Brush, Pen, or Geometry) after Freeze() was called or it was sealed by the framework (e.g. used in a resource that got frozen).","commonSituations":"Trying to animate a frozen Brush in a style; animating a shared frozen resource; calling Freeze() earlier in code then later attempting animation.","solutions":["Animate a non-frozen surrogate: put the brush on the element and animate the element property, or use Clone() to get an unfrozen copy.","Do not Freeze() objects you intend to animate later.","Check freezable.CanFreeze / IsFrozen before deciding to freeze; keep animatable instances unfrozen."],"exampleFix":"// before\nbrush.Freeze();\nbrush.ApplyAnimationClock(SolidColorBrush.ColorProperty, clock); // sealed -> throws\n// after\nvar animatableBrush = brush.Clone();\nanimatableBrush.ApplyAnimationClock(SolidColorBrush.ColorProperty, clock);","handlingStrategy":"type-guard","validationCode":"var f = element as Freezable;\nif (f != null && f.IsFrozen) { element = f.Clone(); } // animate the unfrozen clone","typeGuard":"bool CanBeAnimated(DependencyObject o) => o is not Freezable f || !f.IsFrozen;","tryCatchPattern":"try { element.ApplyAnimationClock(dp, clock); }\ncatch (InvalidOperationException) { var clone = ((Freezable)element).Clone(); clone.ApplyAnimationClock(dp, clock); }","preventionTips":["Do not Freeze() objects you plan to animate.","Check Freezable.IsFrozen before animating.","Animate owning elements (e.g. element.Opacity) instead of frozen brushes/resources."],"tags":["wpf","animation","invalidoperationexception","freezable"],"backgroundTag":"invalid-state-transition","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"}