{"record":{"id":"0dc27b36d18b4aa3","repo":"dotnet/wpf","slug":"animation-dependencypropertyisnotanimatable","errorCode":"Animation_DependencyPropertyIsNotAnimatable","errorMessage":"SR.Animation_DependencyPropertyIsNotAnimatable (Animation_DependencyPropertyIsNotAnimatable)","messagePattern":"SR\\.Animation_DependencyPropertyIsNotAnimatable \\(Animation_DependencyPropertyIsNotAnimatable\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Animatable.cs","lineNumber":70,"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":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Animatable.cs#L52-L88","documentation":"ApplyAnimationClock was called with a DependencyProperty that WPF does not consider animatable (AnimationStorage.IsPropertyAnimatable returned false). WPF only allows animating dependency properties registered with the 'readable, writable, animatable' (Media.AnimationRead) flags, i.e. registered via DependencyProperty.Register with animate support. This ArgumentException protects the animation subsystem from targets that cannot host animation clocks.","triggerScenarios":"Calling animatable.ApplyAnimationClock(dp, clock) where dp was registered without animation support (e.g. a custom DependencyProperty registered without the animatable flag, a read-only property, or a property that is not a DP at all resolved by name lookup).","commonSituations":"Custom controls registering DPs without animatable metadata; animating read-only DPs (e.g. ActualWidth); using reflection/property lookup to grab the wrong DP; porting code from a library version where the property was not yet animatable.","solutions":["Verify the DependencyProperty you pass is a real, writable, animatable DP (check Animatable.GetLocalValueEnumerator or the property's metadata); use the static XXXProperty field (e.g. UIElement.OpacityProperty) rather than a looked-up name.","If it is your own property, re-register it with the animation-capable metadata (AddOwner/OverrideMetadata from an animatable owner or register with the appropriate framework flags).","For read-only properties, animate a substitute (e.g. a bound writable property) or use PropertyPath-based storyboard animation on an animatable wrapper."],"exampleFix":"// before\nanim.ApplyAnimationClock(SomeControl.MyPropProperty, clock); // MyProp registered without animatable support\n// after\nanim.ApplyAnimationClock(UIElement.OpacityProperty, clock); // well-known animatable DP","handlingStrategy":"validation","validationCode":"if (dp == null || !AnimationStorage.IsPropertyAnimatable(target, dp))\n    throw new ArgumentException($\"{dp?.Name} on {target.GetType()} is not animatable\");","typeGuard":"static bool IsAnimatable(DependencyObject o, DependencyProperty dp) => dp != null && !dp.ReadOnly && AnimationStorage.IsPropertyAnimatable(o, dp);","tryCatchPattern":"try { target.ApplyAnimationClock(dp, clock); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(dp)) { /* log: property not animatable */ }","preventionTips":["Always reference the static XXXProperty field, not a name lookup.","Register custom DPs with animation-capable metadata.","Never attempt to animate read-only DPs."],"tags":["wpf","animation","dependency-property","invalid-argument"],"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"}