Control.DefaultStyleKey Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the key that references the default style for the control.

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

Syntax

'Declaration
Protected Property DefaultStyleKey As Object
protected Object DefaultStyleKey { get; set; }

Property Value

Type: System.Object
The key that references the default style for the control. To work correctly as part of theme style lookup, this value is expected to be the Type of the control being styled.

Remarks

Dependency property identifier field: DefaultStyleKeyProperty

To provide a default Style for a control that inherits from Control set the DefaultStyleKey property to the same type of the TargetType property. If you do not set the DefaultStyleKey, the default style for the base class is used. For example, if a control called NewButton inherits from Button, to use a new default Style, set DefaultStyleKey to the type, NewButton. If you do not set DefaultStyleKey, the Style for Button is used.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.