自动更新wpf中的列表
我想显示一堆我在列表框中创建的对象。 我的对象实现 INotifyPropertyChanged 接口。 我尝试使用 ObservableCollection,我已将其绑定到列表框控件(listbox1.DataContext = MyCollection) 但这并不完全是我想要做的,因为当 MyCollection 中我的对象之一的属性之一发生更改时,列表框不会刷新。 我发现了这个博客文章: http://sweux.com/blogs/psampaio/index.php/2009/04/13/creating-a-custom-observable-collection-in-wpf
这真的是最简单/唯一的跟踪多个对象的方法?
I want to display a bunch of Objects i have created in a ListBox. My objects implement the INotifyPropertyChanged Interface.
I tried to use an ObservableCollection, which i have bound to a listbox Control (listbox1.DataContext = MyCollection)
But this does not exactly what i want to do, because the Listbox is not refreshed when one of the properties of one of my objects in MyCollection changes.
I have found this blogposting: http://sweux.com/blogs/psampaio/index.php/2009/04/13/creating-a-custom-observable-collection-in-wpf
is this realy the easyiest/only way to keep track of several objects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定,但是您是否尝试过为列表框项目使用数据模板? 例如,将其文本显式设置为适当绑定的文本框。
I'm not sure, but have you tried using a datatemplate for your listbox items? like, a textbox that explicitly sets it's text to the appropriate binding.