Chapter 8. Controls


With the exception of Hyperlink, which is included because it is unique among non-control elements in its support of the Click event, all controls in this chapter belong to the System.Windows.Controls namespace and are ultimately children of the same base class, Control. This gives them a common set of properties and events, but this chapter will detail those specific to each control. Two controls, Grid and StackPanel, are not detailed in this chapter because they provide layout control and are therefore documented in Chapter 10.

Because XAML controls represent .NET CLR controls, they share a common hierarchy (UIElement FrameworkElement Control). For the most part, these base classes are abstract and will never be explicitly declared as XAML elements. Their attributes are inherited by subclasses and have been included to avoid redundancy. Each element description contains a hierarchy so that you can easily reference the inherited attributes.

Attributes that have both a get and set method are generally accessible through XAML, and these values are set in exactly the same way as the properties detailed below. Although an attribute's data type may be type Boolean or Integer, XAML requires that the attribute value be specified as a String. Some elements have attached attributes. These are specifically designated as such, and the concept behind them is discussed in depth in Chapter 3.

There are several structures and elements, detailed in other chapters, that are commonly used to declare attributes. For example, Thickness, detailed in Chapter 7, is the data type for several common Control attributes, such as Margin and Padding. Similarly, Brush is used to describe how to fill the Background attribute of elements. Brush is most often described as a simple, predefined Color (see Appendix G). Table 8-1 lists these common structures/elements, as well as where they are detailed.

Table 8-1. Structures and elements commonly used as attribute types

Structure/element

Description

Where detailed

Brush

Used to fill a region, such as the background area of an element

Chapter 7

Pen

Used to render text or draw outlines

Chapter 7

Thickness

The size of a specific edge of an element

Chapter 7

Color

Describes a color using ScA values or by referencing a pre-defined Color

Chapter 7 and Appendix G

Style

Describes a specific set of attributes such as Color, Thickness, Pen, etc., to be applied to one or more elements

Chapter 10


This chapter also includes a brief reference to common events. A detailed explanation of all events can be found in Chapter 12.




XAML in a Nutshell
XAML in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596526733
EAN: 2147483647
Year: 2007
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net