#128 – Using Code Snippets to Implement a Dependency Property

Visual Studio 2010 includes a code snippet that makes it easier to implement a dependency property in your own class.

To start, right-click on an empty line in your class and pick Insert Snippet.

Double-click on the NetFX30 category.

Then select Define a DependencyProperty.

The code for the code snippet will be added.  (Alternatively, just enter “propdp” in the code editor and press TAB twice).

At this point, you can dbl-click on the property name or its type to enter new values.  When you change the value, it will be changed accordingly throughout the rest of the code snippet.