Silverlight: Listbox bind to CollectionViewSource\List update on remove of item
I have a Listbox that I binds to a resource (sort) CollectionViewSource in my XAML. Then in my cs code I set the CollectionViewSource source to List of objects (class level field)
I then have "remove button" that checks the selected items in the Listbox and removes them from the List of objects (class level field).
I thought the Listbox should update autom开发者_如何转开发atically since the items source updated.
Am I missing a step or property setting ? Or am I missing something about how binding works?
tep
The class that contains your list of objects must implement INotifyPropertyChanged
and you must raise the notification event when the list changes, passing in the name of the property that changed. This is what notifies the UI that it must update anything bound to that property.
Alternatively, make your collection of objects an ObservableCollection<T>
and that will do the notifying for you.
精彩评论