All posts by ravik18

WPF Class Hierarchy

Dispatcher Object

WPF uses a single-threaded model it means the entire UI is owned by a single thread. So you can’t access UI Elements from another thread. To overcome this situation WPF introduced a dispatcher. Almost all UI Elements are derived from the DispatcherObject class. This class contains two methods CheckAccess and VerifyAccess. CheckAccess method returns true if the calling thread has access to this object and VerifyAccess throws an exception if the calling thread does not have access to that object. So using this simple functionality all WPF objects are being able to determine that they only used by UI Thread.

Dependency Object

Dependency Object is the base class that supports Dependency Property and Attached Property. The Dependency Properties are used in Data Binding. You can create your own Dependency Property by deriving Dependency Object to you own class. Dependency Object has two Major methods GetValue and SetValue. GetValue method used to get value from Dependency Property and SetValue method used to set value to Dependency Property.

Visual

Each and every element that has visual representation and appears in WPF Window is derived from Visual class. Visual class provides some basic Drawing functionality to encapsulate drawing instructions also some drawing related information like clipping, opacity etc. It also has some basic methods to add and remove visuals. Visual class also provides link between managed libraries and milcore.dll that renders display.

UI Element

UI Element added support for Layout, Focus, Input, Event, command bindings, etc. These are the core and essential features of WPF. At UI element level basic layout is introduced – Measure and Arrange passes. The measure allows determining that how much size it would take and Arrange allows a parent to determine the final size of each child. UI Element also introduces the notation of command binding.

Framework Element

Framework element extends layout features of UI Element and adds support for features like data binding, animation and styles. It also supports key properties like HorizontalAlignment, VerticalAlignment, and Margin etc.

Control

Control is the base class for almost all controls available in WPF such as Button, StatusBar, Combobox, Label, etc. At this level many control level properties introduced like background, foreground, and Font related properties like FontSize, FontStyle, font-weight, etc.

For more info, you can watch below video.

WPF Architecture

In this blog, we will learn WPF Architecture. WPF is used for developing desktop application and was introduced by Microsoft in .NET Framework 3.5 as a replacement of Windows forms.

It has mainly 2 parts – WPF module and OS core Module. WPF module is sub divided in 2 parts – Managed Module ( Core WPF elements) and un-managed module which acts as a bridge between WPF managed module and OS Core element.

Managed Module:

PresentationFramework.dll: This section contains high-level features like application windows, panels, styles controls, layouts, content and so on that helps us to build our application. 

PresentationCore.dll: This is a low-level API exposed by WPF providing features for 2D, 3D, geometry and so on.

WindowsBase.dll: It holds the more basic elements that are capable to be reused outside the WPF environment like Dispatcher objects and Dependency objects.

Un Managed Layer

This section is unmanaged code because it acts as a bridge between WPF managed and the DirectX / User32 unmanaged API.

milCore.dll: It is called the Media Integration Layer (MIL) and resides in milCore.dll. The purpose of the milCore is to interface directly with DirectX and provide basic support for 2D and 3D surface.

WindowsCodecs.dll: WindowsCodecs support in WPF applications like image processing, image displaying and scaling and so on.

Core operating System Layer (Kernel)

This layer has OS core components like User32, GDI, Device Drivers, Graphic cards and so on. These components are used by the application to access low-level APIs.

DirectX: DirectX is the low-level API through which WPF renders all graphics. DirectX talks with drivers and renders the content. 

User32: User32 actually manages memory and process separation. It is the primary core API that every application uses. User32 decides which element will be placed where on the screen. 

GDI: GDI stands for Graphic Device Interface. GDI provides an expanded set of graphics primitives and a number of improvements in rendering quality.

CLR: WPF leverages the full .NET Framework and executes on the Common Language Runtime (CLR).

Device Drivers: Device Drivers are used by the applications to access low-level APIs.

To Summarize it, you can watch this video.

In the next post, we will learn about WPF Class Heirarchy.