AvaloniaUI/Avalonia · error · InvalidOperationException

Animator has no property specified.

Error message

Animator has no property specified.

What it means

Thrown by AnimationInstance<T>.ApplyFinalFill when applying the end-of-animation fill value: the Animator's target AvaloniaProperty is null. FillMode.Forward or FillMode.Both requests a final fill, but no property was declared on the Animator to write the value to.

Source

Thrown at src/Avalonia.Base/Animation/AnimationInstance`1.cs:217

                    return;

                InternalStep(frameTick);
            }
            catch (Exception e)
            {
                PublishError(e);
            }
        }

        private bool CanApplyFinalFill()
        {
            return _fillMode is FillMode.Forward or FillMode.Both;
        }

        private void ApplyFinalFill(T interpolatedValue)
        {
            if (_animator.Property is null)
                throw new InvalidOperationException("Animator has no property specified.");
            _targetControl.SetValue(_animator.Property, interpolatedValue);
        }

        private void DoComplete(bool stopAsIs)
        {
            if (!stopAsIs)
            {
                // Update _lastInterpValue because PublishCompleted might perform final fill
                // and we should ensure that filled value is snapped to last value that animation would
                // reach if it was left running in current state.
                var isIterationReversed = IsIterationReversed(IsAlternatingPlaybackDirection(), _iterationCount + 1);
                _lastInterpValue = FindEdgeValue(IsAnimTimeGoingBackwards(), isIterationReversed);
            }
            _onCompleteAction?.Invoke();
            PublishCompleted();
        }

        private void DoInitialDelay()

View on GitHub (pinned to 11c5427268)

Solutions

  1. Set the Animator.Property to the target AvaloniaProperty (e.g. Visual.OpacityProperty) before running.
  2. Switch FillMode to None so no final fill is attempted (only if fill is genuinely unwanted).
  3. Verify in XAML that the Animator carries the Property= attribute.

Example fix

// before
var animator = new DoubleAnimator(); // Property not set
animation.FillMode = FillMode.Forward;

// after
var animator = new DoubleAnimator { Property = Visual.OpacityProperty };
Defensive patterns

Strategy: type-guard

Validate before calling

if (animator.Property is null)
    throw new InvalidOperationException("Animator.Property must be set before using FillMode.Forward/Both.");

Type guard

static bool HasProperty(Animator a) => a.Property is not null;

Prevention

When it happens

Trigger: Running an animation with FillMode.Forward/Both on an Animator whose Property was never set; triggered at Unsubscribed -> CanApplyFinalFill -> ApplyFinalFill.

Common situations: Defining a code-behind Animator and forgetting to set .Property; building an Animator from XAML where the Property attribute is missing or misspelled.

Related errors


AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13). Data as JSON: /api/errors/4e332750e18e4526. Report an issue: GitHub.