Wpf binding observablecollection not updating

16 Dec

The second step is to let our custom User class implement the INotify Property Changed interface.By doing that, our User objects are capable of alerting the UI layer of changes to its properties.The example is pretty simple, with a User class that will keep the name of the user, a List Box to show them in and some buttons to manipulate both the list and its contents.The Items Source of the list is assigned to a quick list of a couple of users that we create in the window constructor.It looks like this: As you can see, implementing INotify Property Changed is pretty easy, but it does create a bit of extra code on your classes, and adds a bit of extra logic to your properties.This is the price you will have to pay if you want to bind to your own classes and have the changes reflected in the UI immediately.It's called Observable Collection, and you use it much like a regular List - that's all it takes!

wpf binding observablecollection not updating-9wpf binding observablecollection not updating-22wpf binding observablecollection not updating-44

This is just as easy, but once you start doing it, you might discover something that disappoints you: Changes are not automatically reflected, like they were in previous examples.In the On Parent Surface Rendered event you are recreating the annotations on the scichartsurface.Ok that’s good so far, but when adding a Report Tag annotation to the collection it doesn’t update, right?Also I would advise against re-buiding annotations on each re-draw.This can cause performance problems, since adding an annotation could in fact trigger a redraw!Please find the updated Annotation Modifier code below.Observable Collection is one of the most useful classes in WPF and Silverlight data binding.Please use the forums below to ask questions about Sci Chart.Take a moment to read our Question asking guidelines on how to ask a good question and our support policy We also have a tag=Sci Chart on where you can earn rep for your questions!In the Annotation Creation Modifier code you need to subscribe to the Observable Collection&;t Report Tag.Collection Changed event and rebuild your annotations there.