What is the difference between Property and Dependency Property

Dependency properties and standard properties are quite different.

The key features delivered by dependency properties are support for binding and animation. If you want to assign a value to a property using a Binding or template binding that property needs to be a dependency property. When animating a property the a dependency property can track both the current assigned value and the current animated value.

One other advantage that is often overlooked is that storage is only needed for properties that have values assigned. A typical control can have a lot of properties but its rare code that assigns a new value to all the properties, in fact, most of the properties are left at their default value and only few are actually set. With dependency properties the default values are stored as meta-data related to the property and do not require any memory allocated per control instance if the property remains unassigned.

Dependency properties are not limited to controls (anything derived from DependencyObject can have them) however it is on controls or at least FrameworkElements where they are most useful.

Leave a Comment