WPF CONTROLS AND CODE

Windows Presentation Foundation (WPF) provides a whole new method for building user interfaces. Although it bears a superficial resemblance to Windows Forms, WPF provides new controls, a new event architecture, and a new foundation for building and interacting with properties.

WPF also provides tools for separating the user interface from the code behind the interface so that the two pieces can potentially be built by separate user interface designers and Visual Basic developers. It includes a new eXtensible Application Markup Language (XAML, pronounced “zammel”) that lets you build a user interface by using declarative statements rather than executable code. XAML lets you determine the size, position, and other properties of the WPF controls on a form. It lets you define styles that can be shared among many controls, and it lets you define transformations and animations that affect the controls.

As is the case in Windows Forms applications, controls play a central role in WPF applications. Different kinds of controls give information to the user (Label, StatusBar, TreeView, ListView, Image) and organize the information so that it’s easy to understand (Border, StackPanel, DockPanel, TabControl). They enable the user to enter data (TextBox, TextBlock, ComboBox, PasswordBox), select options (RadioButton, CheckBox, ListBox), and control the application (Button, Menu, Slider).

To make an application as effective as possible, you should match controls with your application’s needs. Although many controls may work for a particular task, some controls usually work better than others. For example, you could display status information by changing a button’s caption, but that’s not really what buttons do best. A label in a status bar is usually a better way to give the user status information because the user will expect and understand it. Users generally don’t expect to see status information in a button with changing text.

This chapter briefly describes the most common WPF controls so you can understand which controls work best for different purposes. To help you find the controls you need, the sections later in this chapter group controls by their general function. For example, if you need to display status to the user, look in the section “Providing Feedback.”

I provide only brief descriptions of the WPF controls in this chapter, and some tips that can help you decide which control to use for different purposes. The following chapter, “Using WPF Controls,” covers the controls in much greater detail, describing each control’s most useful properties, methods, and events.


FOR MORE INFORMATION
This chapter and those that follow provide only the briefest glance at WPF. They explain enough to get you started, but for greater detail and more in-depth information, see a book about WPF such as my book WPF Programmer’s Reference: Windows Presentation Foundation with C# 2010 and .NET 4.0 (Wrox, Stephens, 2010, http://www.amazon.com/exec/obidos/ASIN/0470477229/vbhelper).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.238.31