Creating a dependency property
Dependency properties are the workhorse of WPF. This infrastructure provides for many of WPF's features, such as data binding, animations, and visual inheritance. In fact, most of the various element properties are Dependency Properties. Sometimes we need to create such properties for our own controls or windows.
Make sure you have Visual Studio up and running.
How to do it...
We'll create a simple user control with one new dependency property to illustrate the entire procedure:
- Within Visual Studio 2010, create a new WPF Application named CH01.DependencyProperties.
- We'll add a simple User Control, to which we'll add a dependency property. Don't worry if you don't understand exactly what a user control is; ...