StyleHierarchy: Object

     <Style         BasedOn="StyleName"         TargetType="{x:Type NameOfElementOrControl}"         x:Key="Name" /> 

Note that x is replaceable for both the TargetType value and the Key attribute. It refers to the XAML namespace (, which must be included in your document when using this method of reference.

<Style .../> describes the visual presentation of elements. A style contains a collection of Setter, Storyboard, and trigger. Style is explored in depth in Chapter 5.


BasedOn (optional)

Describes the Style this Style attribute is based on.

TargetType (required)

Describes the element or control that is targeted by this Style (Example 10-5).

x :Key (optional)

Names the Style so that it can be referenced by the Style attribute of elements and controls. If this attribute is not set, the style will be applied to all elements of TargetType.

Example 10-5. Examples of targeting an element with a Style

 TargetType="{x:Type MenuItem}" TargetType="{x:Type RadioButton}" 

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

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: