AvaloniaUI/Avalonia · error · InvalidOperationException
Animator has no property specified.
Error message
Animator has no property specified.
What it means
Thrown by SolidColorBrushAnimator.BindAnimation when Property is null. The solid-color animator binds an ISolidColorBrush observable to the target control's property and requires a non-null AvaloniaProperty.
Source
Thrown at src/Avalonia.Base/Animation/Animators/SolidColorBrushAnimator.cs:33
private static readonly DoubleAnimator s_doubleAnimator = new DoubleAnimator();
public override ISolidColorBrush? Interpolate(double progress, ISolidColorBrush? oldValue, ISolidColorBrush? newValue)
{
if (oldValue is null || newValue is null)
{
return progress >= 0.5 ? newValue : oldValue;
}
return new ImmutableSolidColorBrush(
ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color),
s_doubleAnimator.Interpolate(progress, oldValue.Opacity, newValue.Opacity));
}
public override IDisposable BindAnimation(Animatable control, IObservable<ISolidColorBrush?> instance)
{
if (Property is null)
{
throw new InvalidOperationException("Animator has no property specified.");
}
return control.Bind((AvaloniaProperty<IBrush?>)Property, instance, BindingPriority.Animation);
}
}
}
View on GitHub (pinned to 11c5427268)
Solutions
- Set SolidColorBrushAnimator.Property to the brush target property before playing.
- Ensure the target property is brush-typed (Background, Foreground, BorderBrush).
- Confirm the Animator is wired through the correct property in XAML.
Example fix
// before
var animator = new SolidColorBrushAnimator();
// after
var animator = new SolidColorBrushAnimator { Property = Control.BackgroundProperty }; Defensive patterns
Strategy: type-guard
Validate before calling
if (animator.Property is null)
throw new InvalidOperationException("SolidColorBrushAnimator.Property must be set."); Type guard
static bool HasProperty(SolidColorBrushAnimator a) => a.Property is not null;
Prevention
- Set SolidColorBrushAnimator.Property to a brush-typed property at construction.
- Confirm the target property accepts IBrush.
- Validate Property before Play.
When it happens
Trigger: Calling Animation.Play with a SolidColorBrushAnimator that has no Property assigned.
Common situations: Constructing a SolidColorBrushAnimator in code without setting 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.
- Gradient of type {gradientBrush?.GetType()} is not supported
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/b4af2cac479c40fd.
Report an issue: GitHub.