[英]How to notify Property grid collection propery change
I have a wpf application and im using winform host. 我有一个WPF应用程序,即时通讯使用Winform主机。 In some cases the 'SelectedItem' property is complex type that have a property from type 'List'.
在某些情况下,“ SelectedItem”属性是复杂类型,具有来自“列表”类型的属性。 How can i know from code if the collection changed?
我如何从代码中知道集合是否更改? Or just know of the custom editor opened?
还是只知道自定义编辑器已打开?
You can use a ObservableCollection<T>
instead of a List
to have the functionality of indicating changes to the contents of the list. 您可以使用
ObservableCollection<T>
代替List
以具有指示更改列表内容的功能。
The ObservableCollection implements the interfaces INotifyCollectionChanged
and INotifyPropertyChanged
to archive this behaviour. ObservableCollection实现
INotifyCollectionChanged
和INotifyPropertyChanged
接口以存档此行为。
More information to ObservableCollection on MSDN: 有关MSDN上ObservableCollection的更多信息:
https://msdn.microsoft.com/de-de/library/ms668604(v=vs.110).aspx https://msdn.microsoft.com/de-de/library/ms668604(v=vs.110).aspx
If I understand well you have collection of elements, and each of them have some other collection. 如果我理解得很好,您就有了元素的集合,而每个元素都有其他的集合。 In that way you could also consider using BindingList as your base collection - it implements
IRaiseItemChangedEvents
- Indicates whether a class converts property change events to System.ComponentModel.IBindingList.ListChanged
这样,您还可以考虑将BindingList用作基础集合-它实现
IRaiseItemChangedEvents
Indicates whether a class converts property change events to System.ComponentModel.IBindingList.ListChanged
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.