Gets or sets the key to use to reference the style for this control, when theme styles are used or defined.
Assembly: PresentationFramework (in PresentationFramework.dll)
This property is typically not set through any of its direct property accessors. Instead, you override the type-specific metadata of this dependency property every time you create a new FrameworkElement derived class. When you derive a control, call the OverrideMetadata method against the DefaultStyleKeyProperty identifier, within the static constructor of the control derived class (or equivalent class initialization).
A control typically overrides the default value of this property to be its own type, but in some cases could also use a base type for which a style in the theme dictionaries exists. This is only practical if the control templates of the base control entirely define the visual representation of that derived control, and if whatever additional members the derived types expose do not require additional elements as part of the control template.
If you want your element or control to deliberately not use theme styles, set the OverridesDefaultStyle property to true.
The following example illustrates the dependency property metadata override usage discussed in Remarks. This code defines a custom control class NumericUpDown intended to be used from a dedicated control library assembly. The illustrated static constructor references some private initialization function, registers a class handler (another common control subclassing scenario; see Marking Routed Events as Handled, and Class Handling) and finally overrides the dependency property metadata on the NumericUpDown class. always returns its own type as the intended key, which is the convention that the theme style system uses to look up the style for some arbitrary otherwise non-styled control. The complete sample also defines the actual control's theme style that is referenced by that key; see NumericUpDown Custom Control with Theme and UI Automation Support Sample.