Why are dependency properties "static"?
Could someone please explain why dependency properties开发者_开发问答 are declared as static ?
When you declare a DependencyProperty
, you are declaring the definition of that property, rather than the storage space for the property's value (as would be the case with the regular property declaration). There is only one definition of the property for the whole class - as opposed to one definition per instance of the class - and so it is static.
The field you declare as static is only the identifier of a dependency property, not the value of the property. It is shared across all instances of the class, and is used to get/set the value of the property for each instance.
精彩评论