5. Styles and Control Templates
In a word processing document, a "style" is a set of properties
to be applied to ranges of contente.g., text, images, etc. For example, the
name of the style I'm using now is called "Normal,Body,b" and for this document
in pre-publication, that means a font family of Times, a size of 10, and full
justification. Later on in the document, I'll be using a style called
"Code,x,s" that will use a font family of Courier New, a size of 9, and left
justification. Styles are applied to content to produce a certain look when the
content is rendered.
In WPF, a style is also a set
of properties applied to content used for visual rendering. A style can be used
to set properties on an existing visual element, such as setting the font
weight of a Button control, or it can be used to define the way an
object looks, such as showing the name and age from a Person object.
In addition to the features in word processing styles
, WPF styles have specific features for building applications, including the
ability to associate different visual effects based on user events, provide
entirely new looks for existing controls, and even designate rendering behavior
for non-visual objects. All of these features come without
the need to build a custom control (although that's still a useful thing to be
able to do, as discussed in
Chapter 9).
 |