是否可以“取消”如果属性值没有更改,则来自 IValueConverter 的依赖属性分配?
我在类的依赖属性上设置了数据绑定。我还有一个 IValueConverter 来处理基于其他元素的该值的计算。我的问题的上下文位于 IValueConverter.Convert 方法内部。
#1
如果计算出的返回值等于当前属性值,我是否可以告诉框架不要打扰 SetValue,因为没有逻辑更改?或者框架会自动检测到这一点,而不是浪费时间在内部设置属性?
#2
如果计算的返回值对此属性无效,我是否可以告诉框架将该属性保留为当前值,而不是将其设置为 DependencyProperty.UnsetValue?
I have a data-binding set on a dependency property of a class. I also have an IValueConverter to handle the calculation of this value based on other elements. The context of my question is inside the IValueConverter.Convert method.
#1
If the calculated return value is equal to the current property value, can I tell the framework not to bother with SetValue since there was no logical change? Or will the framework detect this automatically, and not waste time setting the property internally?
#2
If the calculated return value is invalid for this property, can I tell the framework to leave the property at its current value, rather than setting it to DependencyProperty.UnsetValue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅
Binding.DoNothing
。See
Binding.DoNothing
.