WPF has very deep inheritance class hierarchy and each has its own significance & relationship with other classes. Today we discuss about main classes in WPF hierarchy and its significance.
There are ten main classes in WPF class hierarchy. Below is the diagram for WPF Class hierarchy and we discuss about each class usage in detail.
Object: Object is the main class for all .Net classes and so it is the base class for all WPF classes.
DispatcherObject: It is the base class for any object which wants to accessed only by its own thread. It means the object that derives from DispatcherObject is going to be accessed by only its own thread and if any other thread tries to access that object gives error. In this way DispatcherObject object provides Thread-Safe environment. Most of the WPF classes derive from the DispatcherObject object to provides the Thread-Safe environment. We will discuss moe about DispatcherObject object in my future articles.
DependencyObject: If any object supports dependency properties in WPF means it derives from the base class DependencyObject. DependencyObject provides GetValue() & SetValue() methods that are central to dependency properties.
Freezable: This is the base class for all objects which can be frozen into read-only state for performance reasons. The main advantage of the Freezable objects is, once these objects frozen these can share among multiple threads unlike DispatcherObject objects. Once the object is frozen that can never be unfrozen but can clone them to create unfrozen objects.
Visual: Visual is the base class for all objects which has their own visual representation.
UIElement: It is the base class for all Visual objects with supported events, command binding, layout, focus...etc.
ContentElement: It is similar to UIElement class but some of the pieces don't have rendering behaviour on its own. ContentElements are hosted in a Visual-derived class to rendered on the screen.
FrameworkElement: FrameworkElement is the base class that adds support for styles, data binding, resources, and a few common mechanisms for Windows-based controls such as tooltips and context menus.
FrameworkContentElement: It is analog to FrameworkElement.
Control: The base class for familiar controls such as Button, ListBox, StatusBar....etc. Control adds many properties to its FrameworkElement base class, such as Foreground, Background, FontSize.....etc. Control class also supports templates to replace the complete visual representation.