Blog
Introducing Windows Presentation Foundation - C# 2010
Excerpt by Robert Green and Ken Getz | December 13, 2013
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
Ken Getz
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