开发者

Silverlight: Listbox bind to CollectionViewSource\List update on remove of item

开发者 https://www.devze.com 2023-01-13 04:58 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号