A five-mile overview of WPF

All of my blog entries thus far have assumed that the reader is already fairly familiar with the Windows Presentation Foundation.  In this entry I’ll be taking a step back and covering the basics of WPF.  I hope that this entry proves beneficial to both WPF newcomers and people who need to give a brief overview of WPF to clients/co-workers/managers/etc.

Windows Presentation Foundation (hereafter referred to as WPF) is one of several subsystems comprising the .NET Framework 3.0. WPF is the subsystem responsible for providing modern user interfaces in the realm of desktop, mobile, and browser-based applications. The other subsystems, which are not discussed here, are Windows Communication Foundation, Windows Workflow Foundation, and Windows CardSpace.

The .NET Framework 3.0 is included in Microsoft Windows Vista. Vista UI development will be based on the WPF technology, but WPF is also capable of running on a machine with Windows XP with Service Pack 2, and Windows Server 2003.

Let us take a moment to briefly review the historical context in which WPF exists. The HWND windowing technology has been used by all versions of Microsoft Windows since the first incarnation of the operating system, which was released in 1985. There have been enhancements made to the HWND technology, but it is still the same old system as it always was. WPF replaces the HWND windowing system entirely – from the ground up. WPF is much more than just a set of high-level managed classes, it consists of the following layers:

Media Integration Layer – Abstracts the underlying platform and performs as much graphics processing on a computer’s graphics card as possible, thus freeing the CPU for other processing tasks. It is a complete replacement for Win32 rendering. It performs the task of drawing pixels to the screen.  This layer was written in unmanaged code because raw performance is crucial at this level.

Visual Layer – A set of low-level rendering primitives which provide fine-grained control over the rendering process (in managed code).

Framework Layer – A rich set of high-level managed classes used to build applications on top of the underlying WPF infrastructure. These are the classes that line-of-business application developers will use most often.

For an excellent overview of the layers and how to decide which one(s) to program against, read Pablo Fernicola’s blog entry WPF- Pick Your API Abstraction.

WPF offers the application developer an entirely new palate with which he/she can create appealing and distinctive user interfaces. The following list contains some of the major features (this list is by no means comprehensive):

XAML – eXtensible Application Markup Language is an XML-based language which can be used to declare .NET objects, or, more specifically in the case of WPF, the layout and settings of an application’s user interface. Using XAML to define an application’s UI has several benefits, most notably, it allows graphic designers to work on an application’s visual style without requiring him/her to deal directly with code.

Vector Graphics – The WPF rendering technology is vector-based. Vector-based rendering allows for high-fidelity scaling of complex drawings and text, including the primitive shapes (lines, curves, etc). Another benefit of using vector graphics is it works well with high-resolution displays; something which is becoming a problem for the antiquated HWND technology as the resolution of display units improves.

Documents – WPF has entire namespaces devoted to documents. It provides ample support for different layouts, annotations, packaging, and security. There are several controls that can be used to display high-fidelity documents.  There is also comprehensive support for the XML Paper Specification (XPS), which is a popular means of describing paginated documents via XML markup.

Styles – Styles in WPF are somewhat analogous to CSS classes in Web programming. They allow the developer to create an application-wide visual theme, or a skin for certain controls/pages/windows. There are even designer applications, such as the Microsoft Expression designers, that can be used to facilitate this process.  Styles are a fundamental tool in WPF programming for creating appealing and consistent user interfaces.

Animation – Animating portions of a user interface allows for smooth transitions between logically distinct states, which can make your application more intuitive to the user. They can also be just plain fun. Creating complex animations in WPF is a relatively painless process.

Rich Media Support – One of the major improvements seen in WPF is the rich support for video, audio, and images. WPF exposes this in-depth functionality via managed classes that can easily be incorporated into your applications.  For example, showing a video clip in your user interface is as simple as declaring a MediaElement and specifying the source of the video, all of which can be done in XAML (there’s no need to write a single line of code).

3D – WPF has built-in support for 3D programming. There are classes in the framework which allow the developer to program with 3D meshes, light sources, surface materials, cameras, etc.

Ink-Enabled –WPF has ample support for ink/stylus integration built into it. The core user interface classes include ink/stylus functionality as part of their fundamental design, enabling the platform to be used seamlessly on Tablet PCs.

For those experienced with Win32 programming, or any of the technologies which encapsulate Win32 (such as MFC or Windows Forms), one can immediately recognize that all of the things listed above are either difficult or practically impossible to achieve with HWND-based technology.  WPF literally allows the Windows developer to create an entirely new breed of user interface.

One of the most exciting aspects of WPF is that all of the various feature spaces (as listed above) can be used with each other seamlessly.  For example, you can create a 3D object which is animated to move around the screen, while displaying a video that is “wrapped” around the shape.  If you are interested in seeing some top-notch demonstrations of WPF in action, be sure to check out this blog post.  It provides links to many notable applications which use WPF to create a modern user interface.

It’s a brave new world!

About these ads

One Response to A five-mile overview of WPF

  1. Jeff says:

    The missing intellisense in the 2008 XML editor is an installer bug that disconnects the intellisense driver from Visual Studio. I posted on MSDN about it and they sent me instructions on fixing the registry.

Follow

Get every new post delivered to your Inbox.

Join 288 other followers

%d bloggers like this: