SortedBindingList in WPF

SortedBindingList in WPF

Old forum URL: forums.lhotka.net/forums/t/5947.aspx


JZuerlein posted on Saturday, December 06, 2008

I've noticed some unusual behavior when using a SortedBindingList in WPF. 

I'm binding an EditableRootList to a ListView and a ContentControl.  The ListView shows a list of the items in the collection, and the ContentControl displays the details via a DataTemplate.  It works great until I tell the two controls to bind to a SortedBindingList.

When I remove an item from either the SBL or the ERL, the item is removed from the ListView, but the removed item still appears in the ContentControl (detail data ).  It looks like all the events for ListChanges are getting raised as expected, so I'm suprised it's not working.

Has anyone already ran into this problem?

 

JZuerlein replied on Sunday, December 07, 2008

It looks like the problem was caused because I was calling Remove(T item) rather then RemoveAt(int index).  The Remove(T item) just removes the item from the collection.  It doesn't check to see if the list is sorted, or raise the OnListChanged event. 

Anyone know why Remove doesn't have the same behavior as RemoveAt?

 

Copyright (c) Marimer LLC