Hello,
I'm using a ListBox to maintain a list of items in a WPF application. The ListBox data source is a HashSet wrapped in an ObservableCollection. ie, I have the following code :
this.shackSet = new ObservableCollection<Shack>(new HashSet<Shack>());
this.shackListing.ItemsSource = this.shackSet;
... where shackListing is a ListBox control, and shackSet in an ICollection. However, whenever I add anything to shackSet after the addition of the first item, I see multiple items in the ListBox. ie It's like newly added items are getting added to the list regardless of whether they're added to the set. When I look at the signatures of ICollection#Add :
void Add(T obj);
... and HashSet#Add :
bool Add(T obj);
... this leads me to believe there's a bug that affects wrapped HashSets where newly added items get added to the ListBox regardless because the ObservableCollection has no way of telling whether the object was actually added to the underlaying collection because the return type of ICollection#Add is void. Can anybody else confirm this ?