{"record":{"id":"1242e5660da1d15e","repo":"dotnet/wpf","slug":"sr-ianimatable-cantanimatesealeddo-formatted-with-dp-and","errorCode":null,"errorMessage":"SR.IAnimatable_CantAnimateSealedDO (formatted with dp and this.GetType())","messagePattern":"SR\\.IAnimatable_CantAnimateSealedDO \\(formatted with dp and this\\.GetType\\(\\)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Generated/UIElement.cs","lineNumber":152,"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 (animation != null\n                && !AnimationStorage.IsAnimationValid(dp, animation))\n            {\n                throw new ArgumentException(SR.Format(SR.Animation_AnimationTimelineTypeMismatch, animation.GetType(), dp.Name, dp.PropertyType), nameof(animation));\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.BeginAnimation(this, dp, animation, handoffBehavior);\n        }\n\n        /// <summary>\n        /// Returns true if any properties on this DependencyObject have a\n        /// persistent animation or the object has one or more clocks associated\n        /// with any of its properties.\n        /// </summary>\n        public bool HasAnimatedProperties\n        {\n            get\n            {\n                VerifyAccess();\n\n                return IAnimatable_HasAnimatedProperties;\n            }","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Generated/UIElement.cs#L134-L170","documentation":"UIElement.BeginAnimation throws InvalidOperationException(SR.IAnimatable_CantAnimateSealedDO, formatted with the DP and this.GetType()) when the element IsSealed. Animation mutates the dependency-object's state, which is forbidden on sealed/frozen DependencyObjects, so the library throws before starting the animation.","triggerScenarios":"Calling BeginAnimation on a frozen Freezable (Brush, Pen, Geometry, Transform) or otherwise sealed DependencyObject; animating a shared frozen resource instance.","commonSituations":"Styles/resources that froze a brush, then code tries to animate it; calling Freeze() earlier in the object lifetime; animating a frozen Transform used in a RenderTransform that was frozen for performance.","solutions":["Clone the freezable (Clone()/CloneCurrentValue()) so an unfrozen instance can be animated, then assign it back.","Avoid Freeze() on objects that will be animated.","Animate via the owning element instead (e.g. animate element.RenderTransform's properties on an unfrozen transform)."],"exampleFix":"// before\ntranslateTransform.Freeze();\ntranslateTransform.BeginAnimation(TranslateTransform.XProperty, anim);\n// after\nvar t = translateTransform.Clone(); // keep unfrozen\nt.BeginAnimation(TranslateTransform.XProperty, anim);\nelement.RenderTransform = t;","handlingStrategy":"type-guard","validationCode":"if (target is Freezable fr && fr.IsFrozen) { target = fr.Clone(); } // animate unfrozen instance","typeGuard":"bool CanBeginAnimation(DependencyObject o) => o is not Freezable f || !f.IsFrozen;","tryCatchPattern":"try { target.BeginAnimation(dp, anim, hb); }\ncatch (InvalidOperationException) { var clone = ((Freezable)target).Clone(); clone.BeginAnimation(dp, anim, hb); owner = clone; }","preventionTips":["Skip Freeze() on objects that will be animated.","Check IsFrozen before animation calls.","Animate parent elements rather than frozen shared 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-21T21:30:21.729Z"}