{"record":{"id":"21bc94f1ce9a9009","repo":"dotnet/wpf","slug":"sr-format-sr-ianimatable-cantanimatesealeddo-dp-this-gettype","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/ContentElement.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/ContentElement.cs#L69-L105","documentation":"Thrown by ContentElement.ApplyAnimationClock when the element IsSealed — i.e. the DependencyObject is sealed (typically because it belongs to a frozen or template-sealed state) and can no longer be animated. WPF throws InvalidOperationException with SR.IAnimatable_CantAnimateSealedDO naming the property and element type.","triggerScenarios":"Calling ApplyAnimationClock on a ContentElement whose IsSealed is true, e.g. an element already sealed by the framework (sealed styles/templates or frozen object state) — checked right before AnimationStorage.ApplyAnimationClock.","commonSituations":"Attempting to animate elements inside a sealed template or after the object was sealed; animating shared/frozen resources; applying animations during shutdown or after the element was locked by its container.","solutions":["Check element.IsSealed before animating; skip or clone the element if sealed.","Obtain a mutable copy (e.g. CloneCurrentValue or a new instance) instead of animating the sealed instance.","Move animation code earlier in the element lifecycle, before sealing occurs (e.g. before the template is applied).","Animate an ancestor or a wrapper element instead of the sealed object."],"exampleFix":"// before\ncontentEl.ApplyAnimationClock(dp, clock, HandoffBehavior.Compose);\n// after\nif (!contentEl.IsSealed)\n    contentEl.ApplyAnimationClock(dp, clock, HandoffBehavior.Compose);","handlingStrategy":"validation","validationCode":"if (element.IsSealed)\n    throw new InvalidOperationException($\"Cannot animate sealed element {element.GetType().Name}\");","typeGuard":"bool CanAnimate(ContentElement e) => e != null && !e.IsSealed;","tryCatchPattern":"try { el.ApplyAnimationClock(dp, clock, behavior); }\ncatch (InvalidOperationException ex) when (el.IsSealed) { log.Warn($\"Element {el.GetType().Name} is sealed; skipping animation\"); }","preventionTips":["Check IsSealed before mutating any DependencyObject.","Start animations early in the element lifecycle, before templates/styles seal it.","Clone sealed elements (CloneCurrentValue) rather than animating them in place.","Avoid animating shared or frozen resource instances."],"tags":["wpf","animation","invalid-operation","sealed-object"],"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-21T21:30:21.729Z"}