, ,

Windows Presentation Foundation

Windows Presentation Foundation (WPF) is the answer for software developers
and graphic designers who want to create modern user experiences without having to
master several difficult technologies. Although “Presentation” sounds like a lofty term for
what I would simply call a user interface, it’s probably more appropriate for describing the
higher level of visual polish that’s expected of today’s applications and the wide range of
functionality included in WPF!

The highlights of WPF include the following:

Broad integration—Prior to WPF, a Windows developer who wanted to use 3D,
video, speech, and rich document viewing in addition to normal 2D graphics and
controls would have to learn several independent technologies with a number of
inconsistencies and attempt to blend them together without much built-in support.
But WPF covers all these areas with a consistent programming model as well as tight
integration when each type of media gets composited and rendered. You can apply the same kind of effects consistently across different media types, and many of the
techniques you learn in one area apply to all the other areas.

Resolution independence—Imagine a world in which moving to a higher resolution
or DPI setting doesn’t mean that everything gets smaller; instead, graphics and
text simply get crisper! Envision user interfaces that look reasonable on a small
netbook as well as on a 60-inch TV! WPF makes this easy and gives you the power
to shrink or enlarge elements on the screen independently from the screen’s resolution.
A lot of this is possible because of WPF’s emphasis on vector graphics.

Hardware acceleration—WPF is built on Direct3D, so content in a WPF application—
whether 2D or 3D, graphics, or text—is converted to 3D triangles, textures,
and other Direct3D objects and then rendered by hardware. This means that WPF
applications get the benefits of hardware acceleration for smoother graphics and allaround
better performance (due to work being offloaded to graphics processing
units [GPUs] instead of central processor units [CPUs]). It also ensures that all WPF
applications (not just high-end games) receive benefits from new hardware and
drivers, whose advances typically focus on 3D capabilities. But WPF doesn’t require
high-end graphics hardware; it has a software rendering pipeline as well. This
enables features not yet supported by hardware, enables high-fidelity printing of
any content on the screen, and is used as a fallback mechanism when encountering
inadequate hardware resources (such as an outdated graphics card or even a highend
one that has simply run out of GPU resources such as video memory).

Declarative programming—Declarative programming is not unique to WPF, as
Win16/Win32 programs have used declarative resource scripts to define the layout
of dialog boxes and menus for over 25 years. And .NET programs of all types often
leverage declarative custom attributes plus configuration and resource files based on
Extensible Markup Language (XML). But WPF takes declarative programming to the
next level with Extensible Application Markup Language (XAML; pronounced
“Zammel”). The combination of WPF and XAML is similar to using HTML to define
a user interface—but with an incredible range of expressiveness. This expressiveness
even extends beyond the bounds of user interfaces; WPF uses XAML as a document
format, a representation of 3D models, and more. The result is that graphic designers
are empowered to contribute directly to the look and feel of applications, as well
as some behavior for which you’d typically expect to have to write code. The next
chapter examines XAML in depth.

Rich composition and customization—WPF controls can be composed in ways
never before seen. You can create a ComboBox filled with animated Buttons or a Menu
filled with live video clips! Although these particular customizations might sound
horrible, it’s important that you don’t have to write a bunch of code (or any code!)
to customize controls in ways that the control authors never imagined (unlike
owner-draw in prior technologies). Along the same lines, WPF makes it quite easy to
“skin” applications with radically different looks.

In short, WPF aims to combine the best attributes of systems such as DirectX (3D and hardware acceleration), Windows Forms (developer productivity), Adobe Flash (powerful animation support), and HTML (declarative markup).