| When .NET first appeared, it introduced a small avalanche of new technologies. There was
a whole new way to write web applications (ASP.NET), a whole new way to connect to databases
(ADO.NET), new typesafe languages (C# and VB .NET), and a managed runtime (the
CLR). Not least among these new technologies is Windows Forms, a library of classes for
building Windows applications.
Although Windows Forms is a mature and full-featured toolkit, it’s hardwired to essential
bits of Windows plumbing that haven’t changed much in the past ten years. Most significantly,
Windows Forms relies on the Windows API to create the visual appearance of standard user
interface elements such as buttons, text boxes, check boxes, and so on. As a result, these ingredients
are essentially uncustomizable. For example, if you want to create a stylish glow button
you need to create a custom control and paint every aspect of the button (in all its different
states) using a lower-level drawing model. And don’t even think about introducing animated
effects such as spinning text, shimmering buttons, shrinking windows, or live previews
because you’ll have to paint every detail by hand!
The Windows Presentation Foundation (WPF) changes all this by introducing a new
model with entirely different plumbing. Although WPF includes the standard controls you’re
familiar with, it draws every text, border, and background fill itself. As a result, WPF can provide
much more powerful features that let you alter the way any piece of screen content is
rendered. Using these features, you can restyle common controls such as buttons, often without
writing any code. Similarly, you can use transformation objects to rotate, stretch, scale,
and skew anything in your user interface, and you can even use WPF’s baked-in animation
system to do it right before the user’s eyes.
Underlying the new features in WPF is a powerful new infrastructure based on DirectX,
the hardware-accelerated graphics API that’s commonly used in cutting-edge computer
games. This means that you can use rich graphical effects without incurring the performance
overhead that you’d suffer with Windows Forms. In fact, you even get advanced features such
as support for video files and 3-D content. Using these features (and a good design tool), it’s
possible to create eye-popping user interfaces and visual effects that would have been all but
impossible with Windows Forms.
Although the cutting-edge video, animation, and 3-D features often get the most attention
in WPF, it’s important to note that you can use WPF to build an ordinary Windows
application with standard controls and a straightforward visual appearance. In fact, it’s just as
easy to use common controls in WPF as it is in Windows Forms. Even better, WPF enhances
features that appeal directly to business developers, including a vastly improved data binding
model, a new set of classes for printing content and managing print queues, and a document
feature for displaying large amounts of formatted text. You’ll even get a new model for building
page-based applications that run seamlessly in Internet Explorer and can be launched
from a website, all without the usual security warnings and irritating installation prompts |