AvaloniaUI/Avalonia · error · NotSupportedException
Collection reset not supported.
Error message
Collection reset not supported.
What it means
NotSupportedException ('Collection reset not supported.') thrown by AvaloniaListExtensions.TrackItemPropertyChanged when the observed collection raises a Reset event. By design TrackItemPropertyChanged wires a throwing delegate as the reset handler because it cannot safely re-subscribe property-changed handlers after a wholesale reset, so resets are explicitly unsupported.
Source
Thrown at src/Avalonia.Base/Collections/AvaloniaListExtensions.cs:197
var inpc = x as INotifyPropertyChanged;
if (inpc != null)
{
inpc.PropertyChanged += handler;
tracked.Add(inpc);
}
},
x =>
{
var inpc = x as INotifyPropertyChanged;
if (inpc != null)
{
inpc.PropertyChanged -= handler;
tracked.Remove(inpc);
}
},
() => throw new NotSupportedException("Collection reset not supported."));
return Disposable.Create(() =>
{
foreach (var i in tracked)
{
i.PropertyChanged -= handler;
}
});
}
}
}
View on GitHub (pinned to 11c5427268)
Solutions
- Avoid Reset on the tracked collection — remove items individually instead of calling Clear().
- Dispose the TrackItemPropertyChanged subscription before reloading and re-create it afterward.
- Replace wholesale Clear() with a Remove-based teardown so Reset is never raised.
Example fix
// before using var sub = items.TrackItemPropertyChanged(OnItemChanged); items.Clear(); // raises Reset -> throws // after sub.Dispose(); items.Clear(); using var sub2 = items.TrackItemPropertyChanged(OnItemChanged);
Defensive patterns
Strategy: validation
Validate before calling
sub.Dispose(); collection.Clear(); sub = collection.TrackItemPropertyChanged(callback);
Prevention
- Never Clear() a collection tracked by TrackItemPropertyChanged; dispose first.
- Remove items individually instead of resetting.
- Re-create the subscription after a reload.
When it happens
Trigger: Calling collection.TrackItemPropertyChanged(callback) on a list that subsequently raises NotifyCollectionChangedAction.Reset (Clear, reload, filter change).
Common situations: Tracking PropertyChanged on items in a collection that gets cleared or rebuilt (data refresh, navigation, filtering); ObservableCollection<T>.Clear() which raises Reset.
Related errors
- Reset called on collection without reset handler.
- Reset called on collection without reset handler.
- items
- array
- Multi-dimensional arrays are not supported.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/1830d9df77667b7d.
Report an issue: GitHub.