{"record":{"id":"bf5f40df6e1893ba","repo":"dotnet/wpf","slug":"sr-format-sr-animation-dependencypropertyisnotanimatable-dp-bf5f40","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/UIElement.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/UIElement.cs#L53-L89","documentation":"UIElement.ApplyAnimationClock throws ArgumentException(SR.Animation_DependencyPropertyIsNotAnimatable, paramName \"dp\") when AnimationStorage.IsPropertyAnimatable reports the given DependencyProperty cannot be animated on this element. The library rejects the call early because animating non-animatable properties (not registered as animatable, or not supported on this type) is meaningless.","triggerScenarios":"Calling element.ApplyAnimationClock(dp, clock) where dp is a plain DependencyProperty (e.g. a custom attached property) not registered with Animatable/animation support, or a property that doesn't exist on the element's type.","commonSituations":"Animating a custom control's custom property that wasn't registered as animatable; passing a DP from a different type; typos leading to a non-animatable attached property.","solutions":["Animate a property registered via DependencyProperty.Register with an AnimationTimeline-compatible type, or a known animatable property (e.g. Opacity, Width).","Verify the DP belongs to the element's class or an ancestor.","Wrap the target in a proxy/animatable surrogate property (e.g. animate a DoubleAnimation on a Transform/Brush) if the property itself can't be animated."],"exampleFix":"// before\nrect.ApplyAnimationClock(MyControl.IsSelectedProperty, clock); // not animatable\n// after\nrect.ApplyAnimationClock(OpacityProperty, new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1)));","handlingStrategy":"try-catch","validationCode":"if (dp == null) throw new ArgumentNullException(nameof(dp));\n// Ensure dp is an animatable property of this element's type before calling:\n// e.g. prefer known animatable DPs (Opacity, Width, RenderTransform...)","typeGuard":"bool CanAnimate(UIElement el, DependencyProperty dp) =>\n    dp.OwnerType.IsInstanceOfType(el) && (dp.PropertyType == typeof(double) || dp.PropertyType == typeof(Color) || dp.PropertyType == typeof(Point) || dp.PropertyType == typeof(Thickness));","tryCatchPattern":"try { el.ApplyAnimationClock(dp, clock); }\ncatch (ArgumentException ex) when (ex.ParamName == \"dp\") { Log.Warn($\"{dp.Name} is not animatable on {el.GetType()}\"); }","preventionTips":["Only pass DPs documented as animatable.","Confirm dp.OwnerType is in the element's hierarchy.","Prefer BeginAnimation/Storyboard over raw clocks where possible."],"tags":["wpf","animation","argumentexception"],"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-21T21:30:21.729Z"}