What is a read-only dependency property?

Represents a property that can be set through methods such as, styling, data binding, animation, and inheritance

In WPF, properties are typically exposed as common language runtime (CLR) properties. At a basic level, you could interact with these properties directly and never know that they are implemented as a dependency property. However, you should become familiar with some or all of the features of the WPF property system, so that you can take advantage of these features.

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. In addition, a dependency property can be implemented to provide self-contained validation, default values, callbacks that monitor changes to other properties, and a system that can coerce property values based on potentially runtime information. Derived classes can also change some specific characteristics of an existing property by overriding dependency property metadata, rather than overriding the actual implementation of existing properties or creating new properties

This example registers the default value of the State dependency property to be false

public class MyStateControl : ButtonBase


  public MyStateControl() : base() { }

  public Boolean State


    get { return (Boolean)this.GetValue(StateProperty); }

    set { this.SetValue(StateProperty, value); }


  public static readonly DependencyProperty StateProperty = DependencyProperty.Register(

    "State", typeof(Boolean), typeof(MyStateControl),new PropertyMetadata(false));





1.       Dependency Property

2.       Custom Dependency Properties