Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
DefaultStyleKey Property

FrameworkContentElement.DefaultStyleKey Property

Gets or sets the key to use to find the style template for this control in themes.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)

'Declaration
Protected Friend Property DefaultStyleKey As Object

Property Value

Type: System.Object
The style key. To work correctly as part of theme style lookup, this value is expected to be the Type of the element being styled. Nothing is an accepted value for a certain case; see Remarks.

Identifier field

DefaultStyleKeyProperty

Metadata properties set to true

AffectsMeasure

This property is typically not set through any of its direct setters. Instead, you override the type-specific metadata of this dependency property every time you create a new subclass. When you subclass, call the OverrideMetadata method against the DefaultStyleKeyProperty identifier, within the static constructor of the control subclass.

For instance, an inline class such as Bold actually has very little implementation beyond overriding the DefaultStyleKey metadata in its static constructor, and exposing several instance constructors. The fact that elements surrounded by the Bold tag gain a FontWeight property of Bold is implemented within the theme style that was referenced by setting the default value of DefaultStyleKey to typeof(Bold).

If you want your element or control to deliberately not use theme styles, set the OverridesDefaultStyle property to true.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft