绑定列表和UI控件,不更新的编辑 [英] Binding List and UI controls, not updating on edit

查看:182
本文介绍了绑定列表和UI控件,不更新的编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我绑定的BindingList双向到列表框。绑定列表中包含的数字。如果项目被添加或从绑定列表中删除,这显然只更新列表框图像。我怎样才能让这个对的BindingList也提出,当一个项目被修改ListChanged事件

I am binding a BindingList two way to a listbox. The Binding list contains a number of images which apparently only update the listbox if items are added or removed from the binding list. How can I make it so that the bindinglist also raises the listchanged event when an item is modified?

编辑:我发现我遇到的问题是,一个属性。对象不被改变,而基本对象

I find the problem I am having is that a property of an object is not being changed, rather the base object.

BindingList<ImageSource>();



不过,这不会工作,如果我这样做:

This wont work however if I did this:

BindingList<Image>();



然后设置到Image.Source结合路径,这将正确地更新,这是因为一个属性图像的已改变,但在第一实施例的情况下,仅在列表中直接项已改变。所以,我怎么可能会得到相同的行为第二个例子

And then set the binding path to Image.Source, it would update correctly and this is because a property of the Image has changed but in the case of the first example, only a direct item in the list has changed. So how may I get the same behaviour as the second example?

最后编辑:好像使用的ObservableCollection代替的BindingList修复此问题。我是,他们在该集合中的变化的通知是相同的印象。以下

FINAL EDIT : It seems that using ObservableCollection instead of BindingList fixes this issue. I was under the impression that they were identical in notifying of changes in the collection. Full answer below

推荐答案

的的的BindingList 的ObservableCollection <不同/ A>在的BindingList不会通知其直接的项目被改变(当项目被添加或从集合中删除除外)。但是实现的ObservableCollection和INotifyCollectionChanged接口INotifyPropertyChanged的。这意味着,要一个ObservableCollection直接项目的任何变化被报告给用户界面。

The BindingList differs from ObservableCollection in that BindingList does not notify that its direct items are changed (except when items are added or removed from the collection). ObservableCollection however implements INotifyCollectionChanged and INotifyPropertyChanged interfaces. This means that any change to direct items of an ObservableCollection are reported to the UI.

如果您使用的绑定到引导项目和需要更新的项目,而不是那些性质项目,似乎你必须使用的ObservableCollection。另一个解决方案是从的BindingList派生并实现INotifyCollectionChanged。

If you are using bindings to direct items and need to update items and not properties of those items, it seems that you have to use ObservableCollection. Another solution would be to derive from BindingList and implement INotifyCollectionChanged.

我不是专家,但是这是我的最后一个小时内已经聚集,如果任何人有什么要补充或正确,请让我知道。

I am not an expert but this is what i have gathered during the last hour, if anyone has anything to add or correct please let me know.

这篇关于绑定列表和UI控件,不更新的编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆