Observablecollection not updating
There’s no need to subscribe to the event, the UI does this automatically.Immersive Tip: snap Visual Studio and your browser window next to each other and rewrite the code yourself on this page while carefully analyzing the Intelli Sense. When running it now, you’ll see your UI updating both when the collection gets modified and its children’s properties get modified.Here in this case we need to call the Refresh method of Collection View Source.
One being when an item gets added to the collection, the other being when an item already added gets modified.Microsoft provides two interfaces to deal with those: INotify Collection Changed and INotify Property Changed respectively.Add a Change and Add button on your form, and wire them up so they change/add an item in the collection of employees.Again, this might be basic for some, but it’s an essential skill to master and it applies to both WPF, Silverlight and Windows 8 development.Observable Collection is one of the most useful classes in WPF and Silverlight data binding.Even Scott Hanselman made this mistake on stage at Mix ‘09 (skip to ).The problem is that after you swap out one Observable Collection for a new one, the view is still bound to the old one.(Forget about Lists, and always use Observable Collections! I won’t cover INotify Collection Changed as it’s very similar to INotify Property Changed (you can easily figure it out yourself) and I’ll use the Observable Collection instead.Change our collection list to an Observable one right now.Whenever you modify the collection, the view is notified. These are some of the mistakes I see from beginners and experts alike.When a view binds to an Observable Collection, it subscribes to events from that instance.