Observablecollection not updating

The handler completes before the Add or Remove method returns.This means that you can’t modify an Observable Collection in a background thread.This causes the view to unbind from the old one and rebind to the new one.In this situation, the view can’t adjust to just the items that were added or removed; it has to rebind the entire list box.

When an Observable Collection is modified, it raises an event. Event handlers respond on the same thread as the modification.If we step through the debugger, though, we can verify that everything is wired up correctly. The logic is pretty straightforward - feel free to kick yourself like I did when I figured it out.Observable Collection raises a Collection Changed event whenever an item is added or removed - the Items Source binding will listen for this event and refresh appropriately.The problem is that after you swap out one Observable Collection for a new one, the view is still bound to the old one.A common “fix” for this problem is to fire a Property Changed event to notify the view that the collection has been replaced.

Leave a Reply