WPF Class Hierarchy

Important Classes of WPF Architecture

DispatcherObject

Namespace: System.Windows.Threading
Assembly: WindowsBase (in WindowsBase.dll)

Most of the objects in WPF are derive from DispatcherObject. Basically it deals with threading and concurrency(happening at the same time). It acts like a main engine that take care all the work done priority basis on the UI thread and how the dispatcher of other threads delegates their tasks to UI thread to access the UI controls. Here two concepts are there to understand – the dispatcher thread and thread affinity.

DependencyObject

Namespace: System.Windows
Assembly: WindowsBase (in WindowsBase.dll)

In WPF there is preference given to properties over methods and events because they are declarative and provide a data driven system. Hence there is more control over the behavior of application. So WPF provides a richer property system which includes Dependency Properties, Attached properties.

Dependency Properties:
Provides much more richer functionality than a normal CLR property can provide. The example of its richness is like the change notification, where the property system tracks dependencies between properties and system is automatically updated when property changes.

Attached Properties:
WPF property system also provides distributed storage of property values. Its ok if you don’t understand this statement, continue reading you will know its meaning. In WPF, the object instances are not required to carry the full weight of all the properties defined on it. So the WPF elements are allowed to provide property definitions to its containing elements. Thereby there is no need to associated all the properties to every element.

Visual

Namespace: System.Windows.Media
Assembly: PresentationCore (in PresentationCore.dll)

Its core role is to provide rendering support to WPF, how the pixels are drawn on screen. It is basically a connection point of Managed API and Unmanaged Milcore. Here WPF provides a Visual Class which provide a tree of Visual objects (Every Framework element have Visual as its base class in the object hierarchy). This class also supports hit testing, bounding box transformation, coordinates transformation.

UI Element

Namespace: System.Windows
Assembly: PresentationCore.dll

UI Element is derive from Visual which is a high level graphics class. All the Framework Elements are derive from UI Element class. It provides them the basic presentation characteristics. UIElement defines core subsystems including Layout, Input, and Events.

Capabilities of UI Element

  • Render as a Child element
  • Provide support for the size and position for the containing elements
  • Respond to user inputs
  • Raise Routed Elements
  • Provide some support for animation

FrameworkElement

Namespace: System.Windows
Assembly: PresentationFramework.dll