简体   繁体   English

通过属性网格编辑可观察的集合

[英]Editing observable collection via property grid

I have a class with observable collection property and I edit this property with PropertyGrid. 我有一个带有可观察集合属性的类,并使用PropertyGrid编辑了此属性。 When I remove some items from it and press OK button my collection starting to fire CollectionChanged events, but it doesn't fire event with Remove Action. 当我从其中删除某些项目并按OK按钮时,我的收藏集开始触发CollectionChanged事件,但是使用Remove Action不会触发该事件。 Firstly it fires event with Reset action and then it fires events with Add action of remain items. 首先,它使用“重置”动作触发事件,然后使用“剩余项目”的“添加”动作触发事件。

How can I get when collection fires last CollectionChanged event? 当集合触发最后一个CollectionChanged事件时,我如何获取?

How can I get which items was removed? 我如何获取已删除的项目?

Well, I did a pretty weird solution, but it worked for me, mb it gonna help someone later. 好吧,我做了一个很奇怪的解决方案,但是它对我有用,但后来会帮助别人的。 It has some obviously evil sides, but for now it is still better than nothing. 它显然有一些邪恶的一面,但到目前为止,总比没有好。

Everytime when CollectionChanged fired I start my local timer with, for example, 500ms interval, if timer is elapsed - last collection changed event already triggered. 每次触发CollectionChanged时,如果经过了计时器,我就会以例如500毫秒的间隔启动本地计时器-已经触发了上次更改收藏夹事件。

Also I have a local copy of unique IDs of items in my observable collection, so after timer elapsing I can check which items was removed from collection, so i can clean data which was binded on it. 另外,我在可观察的集合中有项的唯一ID的本地副本,因此在经过计时器后,我可以检查从集合中删除了哪些项,以便可以清理绑定在其上的数据。

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

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