Benefits of WPF Technology

Publish Date: Jul 31, 2012 | 0 Ratings | 0.00 out of 5 | Print


As described in the previous article, Introduction to WPF Technology, Windows Presentation Foundation (WPF) was created to fill a need for better tools for user interface (UI) development. The benefits of WPF are different depending on the scenario. In this tutorial, we describe the benefits from both a business perspective as well as in terms of the technical tools and features.

Table of Contents

  1. Business Benefits
  2. Technical Features
  3. Additional Resources

1. Business Benefits

The decision to choose WPF as the UI design platform for your next project should be based on whether your user experience requirements necessitate more features than allowed by Windows Forms. Once you have opted to use WPF, you now have the opportunity to structure your project team such that designers and developers can focus their individual skills on tasks that complement each other and create a more modular finished product.

Stand Out From Your Competitors

For those of you who develop applications to sell, the UI is often the “cover” to your book—the crucial first impression. The user experience shapes the perception of quality of the application because it’s the only way to give commands and receive feedback from your application. An attractive intuitive UI implies a thorough, professional development team whereas an outdated or difficult-to-use UI can turn off potential clients.

WPF technology makes it easier to create an intuitive UI because it allows developers to copy user interactions that their customers are already familiar with, such as swiping icons and menus into view or zooming via multitouch, as is common with most smartphones today. A UI that’s intuitive to operate makes the user’s job easier because they spend less time trying to figure out how to complete their task, which translates to less frustration and questions to the provider.

Additionally, WPF provides the tools to build a more beautiful and immersive UI than your competition. One cannot ignore the powerful affect of simply enjoying using a piece of software because it looks great and has an enhanced feel or slick behavior. This may not have been important in the past but the web, tablets, and smartphones have changed that. The modern software UI will continue to look better regardless of the industry it’s used in and WPF makes it straightforward to implement the features, such as media, 2D and 3D graphics, animations, web-like characteristics, and much more, that can enhance that look and feel.

Help Developers and Designers Work Together

At some point, you may decide to hire a professional interface designer to help you achieve the comprehensive and stylized UI that your software deserves. This allows software developers to focus on what they do best—writing code logic—and shifts the UI design piece to designers who possess a very different set of skills. Today designers and developers cannot easily collaborate on an application. Most commonly, a designer uses a graphical tool to create static images of the screen layouts, and then gives these images to the developer whose job is to create the code that makes them real. Something that’s easy for a designer to draw, however, might be difficult or impossible for a developer to implement. Technology limitations, schedule pressures, lack of skill, misunderstandings, or simple disagreement might prevent the developer from fully realizing the designer’s vision. What’s needed is a better way for members of these two interdependent disciplines to work together without compromising the quality of the interface.

To allow this, WPF introduces the eXtensible Application Markup Language (XAML), which defines a set of XML elements to describe exactly how a UI looks. XAML offers a tool-friendly way to describe a UI and it provides a better way for developers and designers to work together. A designer can specify how a UI should look and interact using a tool such as Microsoft Expression Blend. Then a developer can import that XAML description into a tool such as Microsoft Visual Studio. Rather than recreating the interface from scratch based on static images produced by a designer, the interface definition itself is adopted wholesale. The developer then writes the code for the interface, such as event handlers, along with any other functionality the application requires. This lets designers and developers work in parallel with quicker iteration and less translation errors, resulting in faster turnaround and a better-quality product.

Back to Top

2. Technical Features

In this section, take a deeper look into particular facets of the technology that are unique and present new benefits over other programming paradigms.

Unified Platform for Modern UIs

Prior to WPF, programmers would have to use several different technologies to create a powerful UI. For example, to create the forms, controls, and other typical aspects of a Windows graphical user interface, a developer would most likely choose Windows Forms, part of the .NET Framework. If the interface needs to display documents, Windows Forms has some support for onscreen documents, while fixed-format documents might use Adobe PDF. For images and 2D graphics, the developer can use GDI+, a distinct programming model that is also accessible via Windows Forms. To display video and audio, the developer might rely on Windows Media Player, and for 3D graphics, use Direct3D, a standard part of Windows.

WPF provides a single, unified solution that can address all the areas listed above; however, WPF doesn’t replace everything on this list. Even in a WPF world, some new applications will continue to use Direct3D, PDF, and Windows Forms (note that WPF can interoperate with Windows Forms). The big difference is that by combining this functionality into one platform, it makes it significantly easier to program. By requiring programmers to learn only a single environment, WPF can make creating and maintaining applications less expensive. 

Vector Graphics System for Harnessing the Power of Graphics Hardware Acceleration

WPF exploits whatever graphics processing unit (GPU) is available on a system by offloading as much work as possible to it. Modern interfaces also shouldn’t be constrained by the limitations of bit-mapped graphics. Accordingly, WPF relies entirely on vector graphics in contrast to raster graphics. This allows an image to be automatically scaled and resized to fit the size and resolution of the screen it’s displayed on, making the UI more device-independent. Rather than create different graphics for display on a small monitor and a big-screen television, the developer can let WPF handle this to display at the highest resolution supported by the device display without loss of quality. This additionally uses a retained mode graphics system, meaning that everything you draw persists and does not need to be redrawn after the window has been minimized. Retained mode allows the graphics system to optimize the display process.

Intelligent Layout makes Design Easier

WPF provides a multitude of options for arranging components on the application interface and defining their interactive behavior. There are two types of WPF applications: Navigation Window and Document Window. A Navigation Window provides hyperlinks to give the user the ability to move through the application, whereas a Document Window is more like a traditional application. Additionally groups of components can be described using a Panel object, of which there are five standard layout Panels: (1) Canvas provides absolute x, y positioning, (2) DockPanel allows the user to interactively “dock” elements, (3) Grid provides fixed columns and rows for positioning, (4) StackPanel arranges objects into a horizontal or vertical line, and (5) WrapPanel arranges objects as a “flow” in the same way that a web page works.

Controls in WPF are also extremely composable, meaning that you can define almost any type of control as content of another. This flexibility is a powerful feature if you use it appropriately. For example, place an image into a button to create an image button, or place a list of videos into a combobox to choose a video file.

Reusable Templates save Development Time

WPF makes it easy to create reusable elements for your UIs. There are two types of templates in WPF: control templates and data templates. With control templates, you can redefine the way a control looks. For example, if your application needs to have all its list boxes with a blue background and a red border, you could use a control template to redefine the visual appearance of list boxes. Control templates also make it easier for designers to create the “look” for a UI control through a control template, with little to no impact on the actual development process.

Data templates are similar, except that instead of defining the way a control looks, they define the way certain types of data are rendered. Imagine that you have an application dealing with people, such as a contact manager, and that you represent people in code with instances of a Person class. You can create a data template that defines how an instance of a Person is rendered in the UI. For example, an instance of Person might be visualized as a business card with a picture, first name, last name, and telephone number. If you use such a data template, whenever a Person instance is bound to some UI element, such as a list box, WPF will use the corresponding data templates. In practice, you will find that data templates are really handy when dealing with lists or other collections of data.

More Extensive Binding Better Connects Controls to Data

When you hear about binding in WPF, you probably jump immediately to the concept of data binding. Data binding has already been made popular with Windows Forms and ASP.NET Web Forms, and has demonstrated its usefulness there. Although WPF has significant data binding features—significant in that it greatly outclasses its predecessors—it also allows you to declaratively bind other things such as commands, key bindings, animations, and events. For example, you can declaratively bind a button control to a command for pasting.

Advanced Styling Capabilities for Creating Beautiful Interfaces

WPF really shines when it comes to making an application look pretty. You can do such things as make the background of a text box red or surround a button with a thick blue border. Styles are also easy to reuse and allow you to skin controls almost similar to cascading style sheets (CSS) for HTML. Again, WPF styles are richer and have less ambiguity. They encompass all the visual characteristics you would expect, such as padding, margin, position, color, and so on. But you can also use styles to declare nonvisual properties.

Enhance the User Experience with Animation

The animation framework in WPF is very impressive and a great deal more useful than you might think. Most properties in WPF can be animated, and support exists for timelines, key frames, and interpolation. Animations are easily integrated with templates and styles. For example, you might define a style that animates a button when you move your cursor over it. Flash developers and designers will be impressed with the available features.

Unparalleled Customization of 3D Graphics

WPF provides access to a wide range of visual effects for full 3D presentation, including meshes, materials, lights, and textures.

Use Triggers for a Reactive Application

A WPF application delivers a completely new event-handling technology that does away with multiple message loops and uses a message routing system instead. Both templates and styles in WPF support the notion of triggers that give you the ability to declaratively handle changes of state rather than write event handlers into the code as is traditionally done. Each trigger specifies an event that invokes it and an action it performs. This makes it much easier to implement animations that react to user behavior.

Back to Top

3. Additional Resources

Previous Tutorial: Introduction to WPF Technology

Next Tutorial: WPF in Test and Measurement

Back to Windows Presentation Foundation Home Page

Learn about NI Measurement Studio Tools for .NET Developers


Back to Top

Bookmark & Share


Rate this document

Answered Your Question?
Yes No