When collection can contain items of different types (base type and derived type), InsertItem method (and other methods) assumes that items are of the same type (generic parameter). trackable = ChangeTrackingFactory.Default.AsTrackable(item should create trackable objects using actual parameter type, not from formal parameter type instead.
protected override void InsertItem(int index, T item)
{
object trackable = item as IChangeTrackable<T>;
if (trackable == null)
{
trackable = ChangeTrackingFactory.Default.AsTrackable(item, ChangeStatus.Added, _ItemCanceled, _ChangeTrackingSettings, _Graph);
}
base.InsertItem(index, (T)trackable);
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
}
When collection can contain items of different types (base type and derived type), InsertItem method (and other methods) assumes that items are of the same type (generic parameter). trackable = ChangeTrackingFactory.Default.AsTrackable(item should create trackable objects using actual parameter type, not from formal parameter type instead.