AvaloniaUI/Avalonia · error · InvalidOperationException
Animator has no property specified.
Error message
Animator has no property specified.
What it means
Thrown by GradientBrushAnimator.BindAnimation when Property is null. The gradient animator overrides BindAnimation to bind an IGradientBrush observable to the target control's property, and needs a non-null AvaloniaProperty to do so.
Source
Thrown at src/Avalonia.Base/Animation/Animators/GradientBrushAnimator.cs:73
return new ImmutableLinearGradientBrush(
InterpolateStops(progress, oldValue.GradientStops, newValue.GradientStops),
s_doubleAnimator.Interpolate(progress, oldValue.Opacity, newValue.Opacity),
InterpolateTransform(progress, oldValue.Transform, newValue.Transform),
s_relativePointAnimator.Interpolate(progress, oldValue.TransformOrigin, newValue.TransformOrigin),
oldValue.SpreadMethod,
s_relativePointAnimator.Interpolate(progress, oldLinear.StartPoint, newLinear.StartPoint),
s_relativePointAnimator.Interpolate(progress, oldLinear.EndPoint, newLinear.EndPoint));
default:
return progress >= 0.5 ? newValue : oldValue;
}
}
public override IDisposable BindAnimation(Animatable control, IObservable<IGradientBrush?> instance)
{
if (Property is null)
{
throw new InvalidOperationException("Animator has no property specified.");
}
return control.Bind((AvaloniaProperty<IBrush?>)Property, instance, BindingPriority.Animation);
}
private static ImmutableTransform? InterpolateTransform(double progress,
ITransform? oldTransform, ITransform? newTransform)
{
if (oldTransform is TransformOperations oldTransformOperations
&& newTransform is TransformOperations newTransformOperations)
{
return new ImmutableTransform(TransformOperations
.Interpolate(oldTransformOperations, newTransformOperations, progress).Value);
}
if (oldTransform is not null)
{View on GitHub (pinned to 11c5427268)
Solutions
- Set the GradientBrushAnimator.Property to the brush-typed target property before playing.
- Confirm the target property accepts IBrush (e.g. Border.BackgroundProperty).
- Use the correct specialized Animator for the brush kind (SolidColorBrushAnimator vs GradientBrushAnimator).
Example fix
// before
var animator = new GradientBrushAnimator();
// after
var animator = new GradientBrushAnimator { Property = Border.BackgroundProperty }; Defensive patterns
Strategy: type-guard
Validate before calling
if (animator.Property is null)
throw new InvalidOperationException("GradientBrushAnimator.Property must be set."); Type guard
static bool HasProperty(GradientBrushAnimator a) => a.Property is not null;
Prevention
- Set the brush-typed target property when creating a GradientBrushAnimator.
- Pick the correct Animator subclass for the brush kind.
- Verify Property is non-null before Play.
When it happens
Trigger: Calling Animation.Play on a GradientBrushAnimator whose Property has not been set.
Common situations: Animating a gradient property without declaring the target AvaloniaProperty; XAML Animator missing the Property attribute for a gradient brush animation.
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/fa3a8e105af4b4f5.
Report an issue: GitHub.