Introducing Windows Presentation Foundation - C# 2010

Excerpt by Robert Green and Ken Getz

Modern applications require a modern user interface. On the other hand, applications you create using Windows Forms, the standard user interface design package that Visual Studio has provided for past versions, look little different than applications written using tools you might have used in 1995. No matter how you dress them up, forms created using the Windows Forms package generally look pretty much the same, as shown in Figure 1. Although you can create other types of applications, using Windows Forms, you're on your own-the tools exist to create more creative forms, but you must write all the code for each application. You can create non-rectangular forms; you can create forms that scale. But you'll write a lot of code to make it happen.


Figure 1. It's an attractive form, but it looks like every other form. Although Windows Forms provide a rich set of tools for creating business applications, the package leaves a great deal to be desired for building intricate, rich, modern graphically oriented applications. What if you want to create an application that uses a completely new type of interface? Perhaps you don't want rectangular controls, but rather, would like to use your own styles? One thing is for sure: If you've ever seen anyone use a computer interface in a movie or television show, you can be assured that you weren't seeing an application created using Windows Forms.

As you know, creating a visually appealing application using Windows Forms can be challenging. To be honest, up until recently, computer graphics hardware really wasn't powerful enough for a forms package richer than Windows Forms. You can certainly use Windows Forms to create interfaces as you might see in a movie, but it's not easy, and each application you write would require its own set of tools. In addition, using Windows Forms, three-dimensional graphics were extremely difficult without using external libraries. Even then, your code was at the mercy of hardware that might not provide the power necessary to perform the required mathematical calculations.

In addition, the underlying graphics engine, built into Windows for many years, is extremely limited. Windows Presentation Foundation (WPF) provides a new design medium. WPF has been created from the ground up to take advantage of hardware power, and provides a consistent, powerful graphics platform. WPF includes an integrated, vector-based (as opposed to pixel-based) composition engine, which utilizes the power of the computer throughout the graphics stack. In other words, it takes advantage of both the processing power of the computer, and of the GPU (Graphics Processing Unit) built into the graphics hardware. WPF provides full support for resolution independence-as you move from one screen resolution to another, your WPF applications scale appropriately.

WPF introduces a unified approach to user interface, documents, and media: it provides full support for mixing all types of user interaction in a single application. Retrieve input from a user, display a movie, render the contents of a newspaper, all within a WPF application using native controls and rendering support. From a programmer's perspective, WPF makes rich document integration part of the development experience. Unlike Windows Forms, where you can bolt on media support, this support is simply part of WPF. In addition, WPF fully supports separation of design and code, allowing you to bring designers directly into the development process.

Because you can use declarative coding to create your WPF applications, designers can create the user interface with either Visual Studio or other WPF-enabled tools (such as Microsoft's Expressions products), and then you, as a developer, can add the programmatic functionality later. Finally, deployment of WPF applications is easy; it allows administrators to deploy and manage applications securely.

This post is an excerpt from the online courseware Developing Applications with Entity Framework 4.1 Using C# 2010 course written by expert Ken Getz and Robert Green.

Robert Green

Robert Green is a Visual Studio expert and a featured instructor for several of our Visual Basic and Visual C# courses. He is currently a Technical Evangelist in the Developer Platform and Evangelism (DPE) group at Microsoft. He has also worked for Microsoft on the Developer Tools marketing team and as Community Lead on the Visual Basic team. Robert has several years of consulting experience focused on developer training and is a frequent speaker at technology conferences including TechEd, VSLive, VSConnections, and Advisor Live.

Ken Getz

Ken Getz is a featured instructor for several of our Visual Studio courses. He is a Visual Basic and Visual C# expert and has been recognized multiple times as a Microsoft MVP. Ken is a seasoned instructor, successful consultant, and the author or co-author of several best-selling books. He is a frequent speaker at technical conferences like Tech-Ed, VSLive, and DevConnections and he has written for several of the industry's most-respected publications including Visual Studio Magazine, CoDe Magazine, and MSDN Magazine.

This course excerpt was originally posted December 13, 2013 from the online courseware Developing Applications Using C# 2008/2010: Vol 1 by Robert Green and Ken Getz

Entity FrameworkWPFC#