WPF provides a set of services which can be used to extend the CLR properties to provide additional benefits such as automatic UI notifications in the ecosystem. To implement the dependency property, the class must be inherited from the DependencyObject class.
A CLR property reads directly from the private member of the class, whereas a dependency property is stored in a dictionary of keys and values provided by the base class. As the dependency property stores the property only when it is changed, it uses a great deal less memory and is accessed faster.
To easily create a dependency property in a .cs file, use the propdp code snippet. In any class file which is inherited from DependencyObject, write propdp followed by TAB to generate the structure of it. Navigate using the TAB key and change the type, name, owner, and metadata details.
In this recipe, we will learn how to use a dependency property to automatically notify the UI that a change has been...