【发布时间】:2012-07-17 15:36:04
【问题描述】:
在阅读Internals of Dependeny Property in WPF 之后,我想知道如何在 Silverlight for WP7 中实现 Dependeny 属性。调查使用了来自xda forum 的反射器和 Dll。
在 WPF 中:
一个 DependencyProperty 维护所有的静态引用 您在 WPF 对象层次结构中注册的 DependencyProperty。它保持 一个名为 PropertyFromName 的 HashTable,它在内部使用它来获取 DependencyProperty 对象。所以换句话说,每个dependencyProperty 对象注册在全局哈希表中。
在 Silverlight for WP7 DependencyProperties 有几乎相同的全局 HashTable(实际上是
static Dictionary<Type, Dictionary<string, DependencyProperty>> _registeredProperties
)
但是在查看了 DependencyObject 类的 GetValue 和 SetValue 方法的源代码后,我发现 _registeredProperties 根本不使用。
有谁知道为什么以这种方式实现它?或者也许我错过了什么? 提前谢谢你。
【问题讨论】:
标签: c# windows-phone-7 dependency-properties