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
- Remove transitions individually (foreach then Remove) instead of Clear(), or replace the collection instance rather than resetting it.
- If binding Transitions from a VM, reassign the bound property to a new collection rather than Clear()-ing the existing one.
- Avoid Reset notifications from your source collection; use Remove notifications when emptying.
- 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
- Never call Transitions.Clear(); remove items individually or reassign the collection.
- When binding Transitions, replace the VM property with a new collection rather than Clear()-ing.
- Ensure source collections raise Remove, not Reset, when emptied.
- Audit XAML/code-behind for Clear() on transition collections.
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
- No animator registered for the property {setter.Property}. A
- Object of type '{value?.GetType()}' cannot be converted to t
- Animator has no property specified.
- Value must be less than 10.
- Transition elements have different parents.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/3ca82b8216e2df26.
Report an issue: GitHub.