What is a Dependency Property and when is it used?

There have already been a number of discussions here itself regarding this.Please go through some.

What is a dependency property?

What is the Dependency property in WPF

Dependency Property In WPF/SilverLight

How is dependency property implemented?

What is the difference between Property and Dependency Property

Dependency Property Uses in WPF

Also google and you can find some awesome articles.

http://joshsmithonwpf.wordpress.com/2007/06/22/overview-of-dependency-properties-in-wpf/

http://www.switchonthecode.com/tutorials/wpf-tutorial-introduction-to-dependency-properties

http://www.dotnetfunda.com/articles/article961-wpf-tutorial--dependency-property-.aspx


Here is a quote from the WPF 4 Unleashed book:

WPF introduces a new type of property called a dependency property that is used throughout the platform to enable styling, automatic data binding, animation, and more. You might first meet this concept with skepticism, as it complicates the picture of .NET types having simple fields, properties, methods, and events. But when you understand the problems that dependency properties solve, you will likely accept them as a welcome addition.

A dependency property depends on multiple providers for determining its value at any point in time. These providers could be an animation continuously changing its value, a parent element whose property value propagates down to its children, and so on. Arguably the biggest feature of a dependency property is its built-in ability to provide change notification.

The motivation for adding such intelligence to properties is to enable rich functionality directly from declarative markup. The key to WPF’s declarative-friendly design is its heavy use of properties. Button, for example, has 111 public properties (98 of which are inherited from Control and its base classes)! Properties can be easily set in XAML (directly or by using a design tool) without any procedural code. But without the extra plumbing in dependency properties, it would be hard for the simple action of setting properties to get the desired results without the need to write additional code.