AvaloniaUI/Avalonia · error · InvalidOperationException
Transition has no property specified.
Error message
Transition has no property specified.
What it means
Thrown by Transition.Apply when the transition's Property has not been set. Apply needs a concrete AvaloniaProperty to bind the animated observable onto, so a null Property makes animation impossible. This is the internal override reached via the ITransition.Apply path when Property is null.
Source
Thrown at src/Avalonia.Base/Animation/Transition.cs:30
PropertyProperty.Changed.AddClassHandler<Transition<T>>((x, e) => x.OnPropertyPropertyChanged(e));
}
private void OnPropertyPropertyChanged(AvaloniaPropertyChangedEventArgs e)
{
if ((e.NewValue is AvaloniaProperty newValue) && !newValue.PropertyType.IsAssignableFrom(typeof(T)))
throw new InvalidCastException
($"Invalid property type \"{typeof(T).Name}\" for this transition: {GetType().Name}.");
}
/// <summary>
/// Apply interpolation to the property.
/// </summary>
internal abstract IObservable<T> DoTransition(IObservable<double> progress, T oldValue, T newValue);
internal override IDisposable Apply(Animatable control, IClock clock, object? oldValue, object? newValue)
{
if (Property is null)
throw new InvalidOperationException("Transition has no property specified.");
var transition = DoTransition(new TransitionInstance(clock, Delay, Duration), (T)oldValue!, (T)newValue!);
return control.Bind<T>((AvaloniaProperty<T>)Property, transition, Data.BindingPriority.Animation);
}
}
}
View on GitHub (pinned to 11c5427268)
Solutions
- Set transition.Property = Control.PropertyNameField before applying or adding to a Transitions collection.
- In XAML, include Property="Width" (or similar) on every <DoubleTransition>/<ColorTransition> element.
- Validate Property is non-null in a debug assertion when building transitions dynamically.
Example fix
// before
var t = new DoubleTransition { Duration = TimeSpan.FromSeconds(0.3) };
control.Transitions = new Transitions { t }; // Property not set
// after
var t = new DoubleTransition { Duration = TimeSpan.FromSeconds(0.3), Property = Visual.OpacityProperty }; Defensive patterns
Strategy: validation
Validate before calling
if (transition.Property is null)
transition.Property = Visual.OpacityProperty; // set a real target Type guard
static bool IsTransitionReady(TransitionBase t) => t.Property is not null;
Try / catch
if (transition.Property is null) throw new InvalidOperationException("Set Property first");
control.Transitions!.Add(transition); Prevention
- Always set Property when constructing a transition.
- Add a debug Assert(transition.Property != null) before applying.
When it happens
Trigger: Creating a typed Transition<T> (e.g. DoubleTransition) and adding it to Transitions or calling Apply without setting its Property; defining a transition in XAML without a Property attribute.
Common situations: XAML transitions missing the 'Property=' setter; programmatic transitions built fluently where the Property call was forgotten; reusing a transition instance after clearing its Property.
Related errors
- Transition has no property specified.
- Cannot animate direct property {property} on {display}.
- Transition elements have different parents.
- Animator has no property specified.
- Animator has no property specified.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/8e4c52be45c6dcbc.
Report an issue: GitHub.