{"record":{"id":"d07919b6b5df0672","repo":"AvaloniaUI/Avalonia","slug":"cannot-animate-direct-property-property-on-disp","errorCode":null,"errorMessage":"Cannot animate direct property {property} on {display}.","messagePattern":"Cannot animate direct property (.+?) on (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Animation/Transitions.cs","lineNumber":29,"sourceCode":"    {\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"Transitions\"/> class.\n        /// </summary>\n        public Transitions()\n        {\n            ResetBehavior = ResetBehavior.Remove;\n            Validator = this;\n        }\n\n        void IAvaloniaListItemValidator<ITransition>.Validate(ITransition item)\n        {\n            Dispatcher.UIThread.VerifyAccess();\n\n            var property = item.Property;\n            if (property.IsDirect)\n            {\n                var display = item is TransitionBase transition ? transition.DebugDisplay : item.ToString();\n                throw new InvalidOperationException($\"Cannot animate direct property {property} on {display}.\");\n            }\n        }\n    }\n}\n","sourceCodeStart":11,"sourceCodeEnd":34,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Animation/Transitions.cs#L11-L34","documentation":"Thrown by Transitions.Validate when a transition added to a Transitions collection targets a direct (non-styled) AvaloniaProperty. Avalonia's animation system can only bind styled properties, so animating a direct property is unsupported and rejected at insertion time.","triggerScenarios":"Adding a transition whose Property is a DirectProperty (e.g. a class registered via RegisterDirect) to a control's Transitions list; binding a transition to a property declared as direct.","commonSituations":"Mistakenly pointing a DoubleTransition at a direct property like a POCO-style getter/setter property; upgrading a control whose property was changed from styled to direct.","solutions":["Target only styled properties (registered via AvaloniaProperty.Register) in transitions.","If you own the property, re-register it as styled, or wrap it so animation goes through a styled property.","Remove the offending transition from the collection."],"exampleFix":"// before\ncontrol.Transitions = new Transitions\n{\n    new DoubleTransition { Property = MyControl.SomeDirectProperty, Duration = TimeSpan.FromSeconds(0.2) }\n};\n\n// after\ncontrol.Transitions = new Transitions\n{\n    new DoubleTransition { Property = Visual.OpacityProperty, Duration = TimeSpan.FromSeconds(0.2) }\n};","handlingStrategy":"validation","validationCode":"if (transition.Property.IsDirect)\n    throw new InvalidOperationException($\"Cannot animate direct property {transition.Property}\");","typeGuard":"static bool IsAnimatable(AvaloniaProperty p) => !p.IsDirect;","tryCatchPattern":"try { control.Transitions = new Transitions { transition }; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"direct property\"))\n{ /* pick a styled property or drop the transition */ }","preventionTips":["Only target styled properties with transitions.","When authoring controls, expose animatable properties as styled."],"tags":["animation","transition","styled-property","invalid-operation"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}