Unlike usual .Net property, DependencyProperty is defined as static member for a class. The dependencyProperty is not used to store the data as instance members, instead it is used to indicate that the class understands the defined depenency property, so knows how to use this DependencyProperty.
Usually, the class also defines the get/set wrap accessors for the DependencyProperty, they are instance members, since they use the DependencyProperty as key to read and set the data from the hashtable that stores all dependency values.
Note once a DependencyProperty is defined in a class, the value for this property can be set/get to any classes that derived from DependencyObject, not only the class defines it. For example Grid.ColumnProperty in Grid class can be set to a TextField instance. However, only Grid class knows how to apply this property when laying out the TextField. The TextField just stores the value into its DependencyProperty hash table, and never knows what this property really means. In this sense, the DependencyProperty is also called as AttachedProperty.
Jonathan
No comments:
Post a Comment