WPF Styles and Control Templates

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:Articles
.NET Articles

WPF Styles and Control Templates

© 2005 O'Reilly Media
This article—WPF Styles and Control Templates—is from Programming Windows Presentation Foundation, by Chris Sells, Ian Griffiths. Copyright © 2005 O'Reilly Media. All rights reserved. Reproduced by permission. This article has been edited especially for C# Online.NET.

WPF Styles and Control Templates

In a word processing document, a "style" is a set of properties to be applied to ranges of content—e.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.


Previous_Page_.gif Next_Page_.gif




Personal tools