AvaloniaUI/Avalonia · error · InvalidOperationException
Animator has no property specified.
Error message
Animator has no property specified.
What it means
Thrown by Animator<T>.BindAnimation when the Animator's Property is null. BindAnimation binds the animation observable to the target control's property, so it requires a concrete AvaloniaProperty to bind against.
Source
Thrown at src/Avalonia.Base/Animation/Animators/Animator`1.cs:98
return (
KeyFrameInfo.FromKeyFrame(this[Count - 2], neutralValue),
KeyFrameInfo.FromKeyFrame(lastFrame, neutralValue));
}
// Past the last frame which isn't at time 1.0: interpolate between the last frame and 1.0.
var afterValue = lastFrame.FillAfter ? GetTypedValue(lastFrame.Value, neutralValue) : neutralValue;
return (
KeyFrameInfo.FromKeyFrame(lastFrame, neutralValue),
new KeyFrameInfo(1.0, afterValue, lastFrame.KeySpline));
}
private static T GetTypedValue(object? untypedValue, T neutralValue)
=> untypedValue is T value ? value : neutralValue;
public virtual IDisposable BindAnimation(Animatable control, IObservable<T> instance)
{
if (Property is null)
throw new InvalidOperationException("Animator has no property specified.");
return control.Bind((AvaloniaProperty<T>)Property, instance, BindingPriority.Animation);
}
/// <summary>
/// Runs the KeyFrames Animation.
/// </summary>
internal IDisposable Run(Animation animation, Animatable control, IClock? clock, Action? onComplete, bool shouldPauseOnInvisible)
{
var instance = new AnimationInstance<T>(
animation,
control,
this,
clock ?? control.Clock ?? Clock.GlobalClock,
onComplete,
InterpolationHandler,
shouldPauseOnInvisible);
View on GitHub (pinned to 11c5427268)
Solutions
- Set Animator.Property to the target AvaloniaProperty before Play/Apply.
- Construct the Animator via the XAML/animation builder that requires Property.
- Verify the Animator wiring in code-behind at definition time.
Example fix
// before animator.Property = null; animation.Play(control); // after animator.Property = Visual.OpacityProperty; animation.Play(control);
Defensive patterns
Strategy: type-guard
Validate before calling
if (animator.Property is null)
throw new InvalidOperationException("Animator.Property must be set before Play/Apply."); Type guard
static bool HasProperty(Animator a) => a.Property is not null;
Prevention
- Require a Property argument in any Animator construction helper.
- Assert Property is set immediately before calling Animation.Play.
- Audit XAML Animator elements for a missing Property= attribute.
When it happens
Trigger: Calling Animation.Play (which calls Animator.Run -> BindAnimation) on an Animator that has no Property set.
Common situations: Programmatically building an Animator and forgetting Property; XAML Animator element missing the Property attribute.
Related errors
- Animator has no property specified.
- Animator has no property specified.
- Animator has no property specified.
- Animator has no property specified.
- You can only set either {nameof(KeyTime)} or {nameof(Cue)}.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/9890b1e4a0169b96.
Report an issue: GitHub.