AvaloniaUI/Avalonia · error · NotSupportedException

Transitions collection cannot be reset.

Error message

Transitions collection cannot be reset.

What it means

Thrown by Animatable.OnTransitionsCollectionChanged with NotifyCollectionChangedAction.Reset. The transitions system maintains per-transition state and cannot be rebuilt from a generic reset (Clear()), so Avalonia explicitly disallows resetting the Transitions collection via NotSupportedException.

Source

Thrown at src/Avalonia.Base/Animation/Animatable.cs:215

            if (!_transitionsEnabled)
            {
                return;
            }

            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    AddTransitions(e.NewItems!);
                    break;
                case NotifyCollectionChangedAction.Remove:
                    RemoveTransitions(e.OldItems!);
                    break;
                case NotifyCollectionChangedAction.Replace:
                    RemoveTransitions(e.OldItems!);
                    AddTransitions(e.NewItems!);
                    break;
                case NotifyCollectionChangedAction.Reset:
                    throw new NotSupportedException("Transitions collection cannot be reset.");
            }
        }

        private void AddTransitions(IList items)
        {
            if (!_transitionsEnabled)
            {
                return;
            }

            _transitionState ??= new Dictionary<ITransition, TransitionState>();

            for (var i = 0; i < items.Count; ++i)
            {
                var t = (ITransition)items[i]!;

                _transitionState.Add(t, new TransitionState
                {

View on GitHub (pinned to 11c5427268)

Solutions

  1. Remove transitions individually (foreach then Remove) instead of Clear(), or replace the collection instance rather than resetting it.
  2. If binding Transitions from a VM, reassign the bound property to a new collection rather than Clear()-ing the existing one.
  3. Avoid Reset notifications from your source collection; use Remove notifications when emptying.
  4. If you need a fresh set, assign a new TransitionCollection and let the setter swap it.

Example fix

// before
animatable.Transitions.Clear(); // raises Reset -> throws

// after
while (animatable.Transitions.Count > 0)
    animatable.Transitions.RemoveAt(0);
// or:
animatable.Transitions = new TransitionCollection();
Defensive patterns

Strategy: validation

Validate before calling

// never Clear() the transitions collection — remove items or reassign
if (animatable.Transitions is { Count: > 0 } tc)
    while (tc.Count > 0) tc.RemoveAt(tc.Count - 1);
animatable.Transitions = new TransitionCollection();

Prevention

When it happens

Trigger: Calling Animatable.Transitions.Clear() (which raises a Reset action) or reassigning/rebinding a collection that triggers Reset. Any data binding or code that issues CollectionChanged with Action=Reset on the Transitions collection hits this.

Common situations: XAML/binding a transitions collection then clearing it; calling .Clear() on Animatable.Transitions in code-behind; a TwoWay/OneWay binding whose source raises NotifyCollectionChangedAction.Reset (e.g. an ObservableCollection re-init); merging/resetting a CompositeCollection.

Related errors


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