它是否去过能够绑定到一个WPF领域? [英] Has it ever been possible to bind to a field in WPF?

查看:97
本文介绍了它是否去过能够绑定到一个WPF领域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人在<建议href=\"http://stackoverflow.com/questions/5228621/itemscontrol-data-binding-binding-to-the-current-item-isnt-working/5229469#5229469\">another问题的它们,在某些时候,能够在WPF的值绑定到字段

Someone suggested in another question that they, at some point, were able to bind a value to a field in WPF.

我知道,这是<一个href=\"http://stackoverflow.com/questions/842575/why-does-wpf-support-binding-to-properties-of-an-object-but-not-fields\">not支持的情况下(并亲自我只见过用结合的工作性质),但它甚至技术上是可行的?

I know that this is not a supported scenario (and personally I have only seen binding work with properties), but is it even technically possible?

推荐答案

没有。在WPF绑定使用一个的PropertyDescriptor 或依赖属性机制,该机制仅适用于属性。

No. Binding in WPF uses either a PropertyDescriptor or the Dependency Property mechanism, which only works on Properties.

(此处技术说明:一个依赖属性在技术上是那种一个领域 - 它被定​​义为一个字段,然后用DP系统中注册,不过,对待更像是一个属性,所以我想还是把它称为一个属性..该字段本身并不实际的数据存储在DP的情况下)。

(Technical note here: A Dependency Property is technically sort of a field - it's defined as a field, then registered with the DP system, though, and treated more like a property, so I would still call it a property... The field itself doesn't actually store the data in the case of a DP.)

这篇关于它是否去过能够绑定到一个WPF领域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆