本文介绍了更新的PropertyGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能有一个属性网格更新时自动在其SelectedObject属性更改对象吗?我试着在我的类实现INotifyPropertyChanged的,但是属性网格实际上并没有显示在背景中对象的新propertyies,直到我点击它。

How can I have a property grid update automatically when the object in its SelectedObject property changes? I've tried implementing INotifyPropertyChanged in my class but the property grid does not actually show the new propertyies of the object in the background until I click on it.

我试着订阅我的直接对象的PropertyChanged事件,并呼吁PropertyGrid中的Refresh()方法时,它被envoked。但我的一些属性是相关的。这意味着改变一个属性可能会引起多种的PropertyChanged事件。这似乎做工精细,但我仍然不知道是否有通过数据绑定这样做的更清洁的方式。此外,我想,以避免用户只更新单个属性后,控制刷新多次。

I've tried subscribing to the PropertyChanged event of my object directly, and calling the Refresh() method of the PropertyGrid when it is envoked. But some of my properties are related. Meaning changing one property may evoke multiple PropertyChanged events. This seems to work fine, but I'm still wondering if there is a cleaner way of doing this through DataBinding. Also I'd like to avoid having the control Refresh multiple times after the user only updated a single property.

那么,有没有办法让PropertyGrid中从的PropertyChanged刷新事件?

So is there a way to get the PropertyGrid to refresh from PropertyChanged events?

推荐答案

我不知道是否有一个内置的方式做到这一点,但这里有一个建议,如果你想避免刷新多次调用相关属性:

I don't know if there's a built-in way to do it, but here's a suggestion if you want to avoid multiple calls to Refresh for related properties :

的PropertyChanged 事件发生时,启动一个定时器。如果时间尚未达到再次发生时,什么也不做。在计时器的勾选事件,刷新的PropertyGrid 和停止计时器

When a PropertyChanged event occurs, start a timer. If the event occurs again before the timer has elapsed, do nothing. In the Tick event of the timer, refresh the PropertyGrid and stop the timer

这篇关于更新的PropertyGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 09:27