WPF Introduction, Architecture and Core Classes

WPF Introduction, Architecture and Core Classes

WPF is a modern graphical display system for Windows. WPF has innovative features like built-in Hardware Acceleration and Resolution Independence. 

Before WPF, User32 and GDI/GDI+ components were used for creating user interface which had a lot of limitations. Windows Forms and VB6 used these User32 and GDI/GDI+ components for creating user interface.

To overcome limitations of User32 and GDI/GDI+, DirectX was introduced. DirectX is the highly efficient toolkit of game development on Windows and has support for all modern video cards.

WPF uses DirectX instead of GDI/GDI+. User32 is still used but its use by WPF is very limited.

WPF 4.5 is compatible only with Windows Vista, Windows 7 and Windows 8. For Windows XP, you will have to configure Visual Studio to target .NET 4.0 framework rather than .NET 4.5.

WPF Architecture



















WPF Architecture can be divided into three layers:

1. Managed WPF API Layer includes

A) PresentationFramework.dll: Supports WPF types like windows, panels, styles etc.
B) PresentationCore.dll: Supports base types like UIElement and Visuals.
C) WindowsBase.dll: Supports DependencyObject and DispatcherObject.

2. Media Integration Layer includes

A) milcore.dll: This is the core of WPF rendering system and foundation of the Media Integration Layer. Its composition engine translates all WPF visual elements into triangle and textures that Direct3D expects. Although milcore.dll is considered as a part of WPF; it is also an essential system component for Windows Vista and Windows 7. milcore.dll is an unmanaged component. milcore.dll is implemented in unmanaged code because it needs tight integration with Direct3D and because it is extremely performance-sensitive.

B) WindowsCodecs.dll: It provides imaging support for processing, displaying and scaling of bitmaps and JPEGs.

3. DirectX Layer includes

A) Direct3D: Responsible for rendering WPF graphics.
B) User32: It does not play any role in rendering. It is used to determine what program gets what real estate.

Fundamental Namespaces and Core Classes in WPF


System.Threading.DispatcherObject - Supports Single Threaded Affinity (STA).
System.Windows.DependencyObject - Supports dependency properties.
System.Windows.Media.Visual - Supports drawing objects.
System.Windows.UIElement - Supports Layout, Input, Focus and Events (LIFE as acronym).
System.Windows.FrameworkElement - Supports other elements which are left in UIElement.
System.Windows.Shapes.Shape - Supports shapes like rectangle, polygon, ellipse, line, path etc.
System.Windows.Controls.Control - Supports textboxes, buttons, listboxes etc.
System.Windows.Controls.ContentControl - Base class for all the controls that have a single piece of content like label.
System.Windows.Controls.ItemsControl - Base class for all the controls that show a collection of items like ListBox and TreeView.
System.Windows.Controls.Panel - Base class for all the layout containers.

Core Features of WPF:

1. Hardware Acceleration: All WPF drawing is performed by DirectX. DirectX uses GPU (which is a dedicated processor for Video cards) for creating interactive user interface like textures, gradients, animation, 3D drawing, transparency, anti-aliasing etc.

2. Resolution Independence: WPF is flexible enough to scale up or down to suit your monitor and display preferences. WPF uses DIP (Device Independent Unit) which is 1/96 of an inch.

WPF Toolkit: WPF Toolkit includes a set of controls for creating bar, pie, bubble, scatter and line graphs. For more info on WPF Toolkit, you can visit wpf.codeplex.com.