Control Templates
A Style can set just about any property of an element. The examples in the Style section show rather prosaic properties affecting fonts and such. However, a Style for a ListBox could set the ItemTemplate property to a particular DataTemplate, which has more dramatic effects.
For controls, a Style can also set a very important property named Template. That property points to a control template, which determines the visualization of the control.
“Lookless” Controls
In XAML, the behavior of a control, that is, how it responds to user actions in code, is completely separate from the way the control is rendered. In fact, the code for a control normally doesn't contain any information about how the control is rendered at all. The control's rendering is specified by a control template.
Control authors include a default control template in controls. That way, when the control is placed in a XAML page, a default rendering is in place, and the control can be seen and used.
However, that rendering is just the default. The control template can be changed. The new template can make the control look radically different, using any of the visual elements available in XAML.
Reskinning a CheckBox
Suppose you want a CheckBox to control whether a microphone is turned on or off. You could just drag over a CheckBox and be done with it, and from a functional perspective, that would work. However, usability would be significantly enhanced if you could make the CheckBox indicate its function ...
Get Professional Visual Basic 2012 and .NET 4.5 Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.