Windows Forms controls allow you to build powerful desktop applications. WPF (Windows Presentation Foundation) is a new set of controls that you can also use to build desktop applications. While WPF and Windows Forms controls provide many similar features, the WPF controls are more closely tied to high performance graphics libraries so they can provide many sophisticated graphical features that are missing from Windows Forms controls. For example, WPF controls can draw themselves at any scale without losing resolution, can display gradient backgrounds, and can contain other controls in a more flexible and consistent way than Windows Forms controls can. For a specific example of this last feature, a Windows Forms Button control can hold only text. A WPF Button control can hold other controls such as a Grid that contains several Images and TextBlocks to make a much richer experience.
In addition to giving WPF new features, Microsoft is positioning it, or more precisely the Silverlight subset of WPF, for use in building applications on its future platforms. You can build applications in Silverlight for the Windows 8 operating system, the Windows Phone operating system, or web applications. Windows Forms programs still have an important role on desktop systems but Microsoft seems determined to make WPF and Silverlight be the development tools of the future. You can still build Windows Forms applications and run them on the Windows 8 desktop, but you need to use WPF to build programs that can run within the Windows 8 Metro interface.
The WPF (Windows Presentation Foundation) Designer allows you to build WPF windows (including those used by Metro-style applications) interactively much as the Windows Forms Designer lets you build Windows Forms. It provides a WYSIWYG (what you see is what you get) surface where you can add controls to a window. If you select one or more controls on the designer’s surface, the Properties window displays the objects’ properties and lets you edit many of them.
In addition to the WYSIWYG design surface, the designer provides a XAML (Extensible Application Markup Language) code editor. Here you can view and edit the XAML code that defines the user interface. This lets you edit properties and arrange controls in ways that are impossible using the WYSIWYG designer.
This chapter provides an introduction to the WPF Designer. It explains how to add controls to a window, move and size controls, set control properties, and add code to respond to control events.