是否可以“取消”如果属性值没有更改,则来自 IValueConverter 的依赖属性分配?

发布于 2024-08-02 15:15:30 字数 302 浏览 1 评论 0原文

我在类的依赖属性上设置了数据绑定。我还有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文