有用的链接: ObservableCollection类 如何:实现INotifyPropertyChanged接口 I have ListView which I am binding to a Dictionary collection, but new new items are added to the collection, the listview is not updating. How this can be achieved in WPF? 解决方案 Both sides of WPF binding should support INotifyCollectionChanged interface in order to notify about collection changes. Dictionary does not support it. So you can either use ObservableCollection class (it does not provide functionality like search a value by associated key), or you can create you own ObservableDictionary class which implements both IDictionary and INotifyCollectionChanged interfacesPS: If you need bind both keys and values of the Dictionary - you've to implement own class, if it is enough displaying either Keys or Values - simply create ObservableCollection based on dictionary.Keys or dictionary.Values.Useful links:ObservableCollection ClassHow to: Implement the INotifyPropertyChanged Interface 这篇关于集合数据源更新时更新ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-29 14:15
查看更多