Tech Brief

Windows Presentation Foundation

Microsoft's new API for creating slick User Interfaces -- Windows Presentation Foundation (WPF).

In movies and on TV, the main characters are typically an exaggeration of the people you encounter in real life. They're more attractive, they react quicker and they somehow always know exactly what to do. The same could be said about the software they use.

This first struck me back in 1994 when watching the movie "Disclosure," starring Michael Douglas, Demi Moore and an e-mail program that looks nothing like Microsoft Outlook. Throughout the movie, we're treated to various visual features of the program: a spinning three-dimensional "e," messages that unfold when you open them and crumple when you delete them, hints of inking support and slick animations when you print messages.

But real-world software is starting to catch up to Hollywood's standards. Users have increasing expectations for the experience of using software, and companies are spending a great deal of time and money on user interfaces that differentiate themselves from the competition.

New UI Model
Despite the introduction of .NET and Windows Forms in 2002, Microsoft recognized that something brand new was needed that escaped the limitations of current frameworks yet still provided the productivity of Windows Forms. Windows Presentation Foundation (WPF) seeks to offer a consistent programming model for software developers and graphic designers who want to create modern user experiences without having to master several difficult technologies.

WPF is a major component of the .NET Framework 3.0, which is pre-installed with Windows Vista. It can also be installed and used with Windows XP Service Pack 2 and Windows Server 2003.

WPF and XAML
WPF supports an XML-based language called Extensible Application Markup Language, or XAML, for defining user interfaces in a transparent and declarative fashion. The combination of WPF and XAML is similar to using HTML to define a user interface, but with a broader range of expressiveness. This expressiveness even extends beyond the bounds of user interfaces; WPF uses XAML as a document format, a representation of 3-D models, and more. The result is that graphic designers (using a XAML-generating tool such as Microsoft Expression Blend) 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 procedural code. Both Visual Studio and Expression Blend use the same project format, so designers and developers can collaborate on the same projects.

Silverlight (a cross-platform subset of WPF designed for Web browsers) uses XAML in the same way as WPF.

Broad Integration
Prior to WPF, a Windows developer who wanted to use 3-D, video, speech and rich document viewing -- in addition to normal 2-D graphics and controls -- would have to learn several independent technologies 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.

As a result, WPF controls are extremely composable. The WPF composite engine allows you to create a ComboBox filled with animated buttons or a Menu filled with video clips. You don't have to write a bunch of code to customize controls. Along the same lines, WPF makes it quite easy to "skin" applications with radically different looks.

WPF Architecture
[click image for larger view]
WPF Architecture

Content in a WPF application -- whether 2-D or 3-D, graphics or text -- is converted to 3-D triangles, textures and other Direct3D objects and then rendered by hardware. This means that, unlike GDI-based systems, WPF applications get the benefits of hardware acceleration for smoother graphics and all-around better performance (due to work being off-loaded to graphics processing units instead of central processor units). But WPF doesn't require high-end graphics hardware; it has a software-rendering pipeline as well.

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. WPF 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.

The Bottom Line
WPF aims to combine the best attributes of systems such as DirectX, Windows Forms, Adobe Flash and HTML. Visual Studio 2008 fully supports WPF programming (as does Visual Studio 2005 with an add-on for the .NET Framework 3.0), allowing you to work with raw code or with a visual designer instead. For creating the richest WPF-based user interfaces, Expression Blend is the best tool (and geared for designers rather than developers).
comments powered by Disqus
Most   Popular
Upcoming Events

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.