AvaloniaUI/Avalonia · error · InvalidOperationException
Transition has no property specified.
Error message
Transition has no property specified.
What it means
Thrown by the explicit ITransition.Property getter when the public Property is null. Accessing Property through the ITransition interface is treated as required, so a null backing field is a contract violation. This is distinct from [85]: here the throw is on read of the interface-typed Property, not on Apply.
Source
Thrown at src/Avalonia.Base/Animation/TransitionBase.cs:91
/// Gets the easing class to be used.
/// </summary>
public Easing Easing
{
get { return _easing; }
set { SetAndRaise(EasingProperty, ref _easing, value); }
}
/// <inheritdoc cref="ITransition.Property"/>
[DisallowNull]
public AvaloniaProperty? Property
{
get { return _prop; }
set { SetAndRaise(PropertyProperty, ref _prop, value); }
}
AvaloniaProperty ITransition.Property
{
get => Property ?? throw new InvalidOperationException("Transition has no property specified.");
set => Property = value;
}
/// <inheritdoc/>
IDisposable ITransition.Apply(Animatable control, IClock clock, object? oldValue, object? newValue)
=> Apply(control, clock, oldValue, newValue);
internal abstract IDisposable Apply(Animatable control, IClock clock, object? oldValue, object? newValue);
internal override void BuildDebugDisplay(StringBuilder builder, bool includeContent)
{
base.BuildDebugDisplay(builder, includeContent);
DebugDisplayHelper.AppendOptionalValue(builder, nameof(Property), Property, includeContent);
DebugDisplayHelper.AppendOptionalValue(builder, nameof(Duration), Duration, includeContent);
}
}
}
View on GitHub (pinned to 11c5427268)
Solutions
- Always set Property on every transition before exposing or reading it as ITransition.
- When you only have an ITransition, check the public Property via the TransitionBase cast or guard reads in a try/catch.
- Unit-test transition construction to assert Property is assigned.
Example fix
// before
ITransition it = new DoubleTransition { Duration = TimeSpan.FromSeconds(0.3) };
var p = it.Property; // throws
// after
ITransition it = new DoubleTransition { Duration = TimeSpan.FromSeconds(0.3), Property = Visual.OpacityProperty };
var p = it.Property; Defensive patterns
Strategy: validation
Validate before calling
AvaloniaProperty? p = (transition as TransitionBase)?.Property;
if (p is null) { /* configure before reading via ITransition */ } Type guard
static bool HasProperty(ITransition t) => (t as TransitionBase)?.Property is not null;
Try / catch
AvaloniaProperty p;
try { p = it.Property; }
catch (InvalidOperationException) { return; /* skip unconfigured */ } Prevention
- Prefer the TransitionBase-typed Property (nullable) for defensive reads.
- Construct transitions with Property set in one expression.
When it happens
Trigger: Code holding an ITransition reference (not the concrete TransitionBase) reads .Property on a transition that never had Property set; framework internals iterating transitions and reading Property for validation.
Common situations: Adding an incompletely-configured transition to a collection; reflection/serialization code that reads ITransition.Property defensively.
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/929ab37075f78256.
Report an issue: GitHub.