EditorReuseAttribute 的真正用途是什么?
我找不到使用此属性的任何想法?
I can't find any idea of the way to use this attribute?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我找不到使用此属性的任何想法?
I can't find any idea of the way to use this attribute?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
MSDN表示确实是表示一个属性编辑器可以重复使用,而不需要每次都重新创建。
这是性能上的胜利,特别是如果您的编辑器需要在启动时做大量工作,而这是可以避免的。 除非您确实遇到性能问题,否则我不会担心。
MSDN indicates it is indeed to indicate that a property editor can be reused without needing to recreate each time.
This is a performance win, especially if your editor needs to do significant work on start up which can be avoided. Unless you are actually having performance issues then I wouldn't worry about it.
想象一下您有这样的场景:
您的每个属性都有自己的类型设计器,它显示一些属性等。
比如说,您有两个不同的 Complex 类实例 + 某个其他任意类的实例。
现在,当您像这样在对象之间切换时 - 复杂实例 1 -> 其他-> 复杂实例 2 - 一切都会正常工作,但如果你这样做:
复杂实例 1 -> 对于复杂实例 2,您会注意到属性没有被刷新。
这是属性网格的默认行为,它尝试优化数据刷新操作的数量。 除非您想烘焙大量逻辑以使设计人员保持更新,否则我建议将编辑器重用属性设置为 false 来标记您的复杂类型 - 在这种情况下,每当选择更改为不同的实例时,属性网格仍会刷新您的设计师。
imagine you have scenario like this:
each of your properties has its own type designer, which displays some properties, etc.
say, you have two different instances of the Complex class + instance of some other arbitrary class.
now, when you toggle between your objects like this - complex instance 1 -> other -> complex instance 2 - everything will work fine, but if you do something like this:
complex instance 1 -> complex instance 2, you'd notice that properties are not beeing refreshed.
that is default behavior of property grid, which tries to optimize number of data refresh operations. unless you want to bake a lot of logic in order to keep your designers updated, i'd suggest marking your complexTypes with editor reuse attribute set to false - in this case, whenever selection changes to a different instance, property grid would still refresh your designers.
如果您不知道它的作用,为什么需要使用它? 您当前是否有任何正在使用它的代码可以作为示例发布?
听起来它允许您定义属性的属性编辑器可以重复使用而无需重新启动。 我不太确定为什么这会有用。
If you don't know what it does, why do you need to use it? Do you have any code that is using it currently that you could post as an example?
It sounds like it allows you to define that a property editor for your property can be reused without restarting. I am not particularly sure why this would be useful.