What is a dependency property? What is its use?

Thiru G picture Thiru G · Mar 22, 2011 · Viewed 27.7k times · Source

Possiblity:
What is a dependency property?

What is a dependency property? How does it differ from a normal property? What is the purpose of dependency properties? And why it is used, when it is used?

Answer

Shekhar_Pro picture Shekhar_Pro · Mar 22, 2011

Dependency property: A property that is backed by a DependencyProperty.

The purpose of dependency properties is to provide a way to compute the value of a property based on the value of other inputs.

These other inputs might include system properties such as themes and user preference, just-in-time property determination mechanisms such as data binding and animations/storyboards, multiple-use templates such as resources and styles, or values known through parent-child relationships with other elements in the element tree.

It has Following capabilities:

  • The property can be set in a style.

  • The property can be set through data binding.

  • The property can be set with a dynamic resource reference.

  • The property can inherit its value automatically from a parent element in the element tree.

  • The property can be animated.

  • The property can report when the previous value of the property has been changed and the property value can be coerced.

  • The property reports information to WPF, such as whether changing a property value should require the layout system to recompose the visuals for an element.

  • The property receives support in the WPF Designer for Visual Studio. For example, the property can be edited in the Properties window.

(Content taken from MSDN)