{"record":{"id":"354e494c4a62925d","repo":"dotnet/wpf","slug":"sr-format-sr-animation-dependencypropertyisnotanimatable-dp","errorCode":null,"errorMessage":"SR.Format(SR.Animation_DependencyPropertyIsNotAnimatable, dp.Name, this.GetType())","messagePattern":"SR\\.Format\\(SR\\.Animation_DependencyPropertyIsNotAnimatable, dp\\.Name, this\\.GetType\\(\\)\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Generated/ContentElement.cs","lineNumber":71,"sourceCode":"        /// <param name=\"clock\">\n        /// The AnimationClock that will animate the property. If parameter is null\n        /// then animations will be removed from the property if handoffBehavior is\n        /// SnapshotAndReplace; otherwise the method call will have no result.\n        /// </param>\n        /// <param name=\"handoffBehavior\">\n        /// Determines how the new AnimationClock will transition from or\n        /// affect any current animations on the property.\n        /// </param>\n        public void ApplyAnimationClock(\n            DependencyProperty dp,\n            AnimationClock clock,\n            HandoffBehavior handoffBehavior)\n        {\n            ArgumentNullException.ThrowIfNull(dp);\n\n            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","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Generated/ContentElement.cs#L53-L89","documentation":"Thrown by ContentElement.ApplyAnimationClock when the supplied DependencyProperty is not animatable on this element, as determined by AnimationStorage.IsPropertyAnimatable. The library refuses to attach a clock to a property that has no animation support (e.g. a read-only or non-animatable DP), so it fails fast with an ArgumentException naming the property and element type.","triggerScenarios":"Calling ApplyAnimationClock(dp, clock) where AnimationStorage.IsPropertyAnimatable(this, dp) returns false — e.g. dp is a read-only DependencyProperty, a non-animated custom DP, or a property registered without animation support.","commonSituations":"Animating a read-only property like Position or IsMouseOver; applying an animation to a custom DP the developer forgot to mark animatable; animating properties on ContentElement subclasses that only support a subset of DPs; copying animation code from UIElement to a ContentElement property that differs.","solutions":["Verify the target DP is actually animatable: it must be a read-write DependencyProperty registered as animatable (check dp.ReadOnly is false).","Choose a different, animatable property or animate its container/ancestor instead.","If animating your own DP, register it as a normal (non-read-only) DependencyProperty; read-only DPs cannot be animated directly.","Check AnimationStorage.IsPropertyAnimatable(this, dp) before calling ApplyAnimationClock to fail gracefully."],"exampleFix":"// before\ncontentEl.ApplyAnimationClock(UIElement.OpacityProperty, clock);\n// after (Opacity is not a ContentElement DP; pick an animatable property on the element)\nif (AnimationStorage.IsPropertyAnimatable(contentEl, TextElement.FontSizeProperty))\n    contentEl.ApplyAnimationClock(TextElement.FontSizeProperty, clock);","handlingStrategy":"validation","validationCode":"if (dp == null || dp.ReadOnly || !AnimationStorage.IsPropertyAnimatable(element, dp))\n    throw new ArgumentException($\"Property {dp?.Name} is not animatable on {element?.GetType().Name}\");","typeGuard":"bool IsAnimatableOn(ContentElement e, DependencyProperty dp) => dp != null && !dp.ReadOnly && AnimationStorage.IsPropertyAnimatable(e, dp);","tryCatchPattern":"try { el.ApplyAnimationClock(dp, clock); }\ncatch (ArgumentException ex) { log.Warn($\"Cannot animate {dp.Name}: {ex.Message}\"); }","preventionTips":["Only target well-known animatable read-write DPs (FontSize, Foreground, etc.).","Check dp.ReadOnly before animating any property.","Never animate read-only framework properties like IsMouseOver.","Test animation code against the exact element type in unit tests."],"tags":["wpf","animation","dependency-property","argument-exception"],"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"}