Dec 9, 2010 at 1:02 PM
Edited Dec 9, 2010 at 1:04 PM
Are you filling your collection using a background thread?
If so, I suppose that the issue is caused by the fact that the current implementation of
BindableCollection<T> does not perform AddRange as an 'atomic' action from the
Dispatcher point of view (i.e. every call to the Add method is dispatched separately, and the same goes for the final change notification). This approach avoids to stall the
Dispatcher when performing long insert operations, since the Dispatcher can execute some more code between subsequent insert operations, but could lead to problems in case the UI accesses the list before the change notification.
You could try to change the current implementation this way
/// Adds the range.
/// <param name="items">The items.</param>
public void AddRange(IEnumerable<T> items)
IsNotifying = false;
int index = Count;
foreach (T item in items)
IsNotifying = true;
so that the AddRange function is 'atomic' from the Dispatcher point of view, and the UI is not notified of the change until the update process is in progress, and see if the behaviour you are experiencing is gone.
If you are interested on the topic, you can have a look at
this thread from Bea Stollniz.