简体   繁体   English

当observablecollection中的字段更改时,列表框未更新

[英]Listbox not updating when field inside observablecollection is changed

I currently have an issue with my ObservableCollection that is databound to a listbox. 我的ObservableCollection当前有一个数据绑定到列表框的问题。 Whenever I update a field inside of my ObservableCollection in the backend, the UI never refreshes, i have to null the list and reassign it to the binding for the UI to update. 每当我在后端的ObservableCollection内部更新字段时,UI都不会刷新,我必须使列表为空并将其重新分配给要更新的UI绑定。 Any idea as to why this is happening? 知道为什么会这样吗? I've tried a lot of things but nothing changes. 我已经尝试了很多东西,但是没有任何变化。 I'd rather not have to force the UI to update everytime I change a textfield inside of my collection. 我宁愿不必每次更改集合中的文本字段时都强制更新UI。

You have to implement INotifyPropertyChanged on the items of the collection, ie raise the PropertyChanged event when one of their properties changes. 您必须在集合的项目上实现INotifyPropertyChanged ,即,当其属性之一更改时引发PropertyChanged事件。

ObservableCollection only notifies if an element is added or removed. ObservableCollection仅通知是否添加或删除元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM