DependencyObject
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObjectClasses derive from DependencyObject to employ WPF's dependency property (DP) system. The majority
of WPF element types implement their properties using the GetValue and SetValue helper functions provided by DependencyObject. Chapter 18 illustrates this technique.
By handing control of a property to the dependency property system, we can take advantage of data binding, styling, animation, property value inheritance, default values, per-type metadata, and property change notifications.
It is fairly unusual to derive directly from DependencyObject—your classes will normally
derive from one of the other classes described in this appendix,
inheriting from DependencyObject
indirectly. However, one scenario where deriving directly from this
class can be useful is if you are writing a class whose only job is to
act as a data binding source, with values that change on a regular
basis. Although WPF supports ordinary CLR properties and can use the
.NET Framework class library's INotifyPropertyChange interface to discover when properties change, it needs to use reflection to read ordinary properties. However, when binding to a dependency property, WPF provides the property implementation, so it does not need to use reflection to read properties, nor does it need to rely on property change events. This makes binding to a dependency property slightly more efficient than binding to an ordinary ...