Definition:
Dependency property is a new type of property which can be used with dependency objects, to enable styling, data binding or animation. To define your own dependency property you have to register your new property using DependencyProperty.Register(...) method and optionally you can create FrameworkPropertyMetadata object where you can specify property characteristics.
Example:
1: public partial class MinMaxControl : Control
2: {
3: public static readonly DependencyProperty MinProperty =
4: DependencyProperty.Register("Min", typeof(int), typeof(MinMaxControl),
5: new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
6: HandleMinValueChanged, CoerceMinValue), ValidateMinValue);
7: public static readonly DependencyProperty MaxProperty =
8: DependencyProperty.Register("Max", typeof(int), typeof(MinMaxControl),
9: new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
10: HandleMaxValueChanged, CoerceMaxValue), ValidateMaxValue);
11:
12: static MinMaxControl()
13: {
14: DefaultStyleKeyProperty.OverrideMetadata(typeof(MinMaxControl), new FrameworkPropertyMetadata(typeof(MinMaxControl)));
15: }
16:
17: public int Min
18: {
19: get { return (int)GetValue(MinMaxControl.MinProperty); }
20: set { SetValue(MinMaxControl.MinProperty, value); }
21: }
22:
23: public int Max
24: {
25: get { return (int)GetValue(MinMaxControl.MaxProperty); }
26: set { SetValue(MinMaxControl.MaxProperty, value); }
27: }
28: