Possible bug with the BindableCollection?

Topics: Bugs
May 19, 2011 at 9:26 PM


I am not sure if this is expected behavior but if I expose a property on my ViewModel as a BindableCollection and then try to wireup the INotifyCollectionChanged.CollectionChanged event.  I will alway get a event notifications of Reset in the event args.  If I swap out the BindableCollection and use an ObservableCollection the event tracks properly with Add and Remove.

Is this by design?  I have a fairly unique workflow but I am thinking perhaps others would like this behavior as well.

Thanks in advanced,


May 19, 2011 at 9:45 PM

You should only get a Reset notification when invoking BindableCollection.Refresh or when using group operation (AddRange, RemoveRange).

May 19, 2011 at 10:07 PM

Nope, I am getting it for every single add to my collection.  It is very strange.

May 20, 2011 at 2:12 PM

It is, indeed. Try analyzing the stack trace in the event handler to check *where* the event is actually fired.
I'll double check on the trunk.

May 20, 2011 at 2:24 PM

Thanks for checking this.....I will check the stack trace.

May 21, 2011 at 7:43 AM

I'm afraid there is something else going wrong in your scenario. This passes on trunk:

            var Test = new BindableCollection<string>();
            Test.CollectionChanged += (o, e) =>
                Assert(e.Action != System.Collections.Specialized.NotifyCollectionChangedAction.Reset);

            new Thread(x => {

If you get a chance to build a small repro exibiting the problem, file it in the issue tracker or send it to me (marco dot amendola at gmail dot com) and I'll have a look at it.