FrameworkElement.Style Property

Gets or sets any locally applied style used by this element when it is rendered. This is a dependency property.

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

public Style Style { get; set; }
/** @property */
public Style get_Style ()

/** @property */
public void set_Style (Style value)

public function get Style () : Style

public function set Style (value : Style)

<object Style="{resourceExtension styleResourceKey}"/>
 resourceExtension  One of the following: StaticResource, or DynamicResource. See Resources Overview.  styleResourceKey  The key that identifies the style being requested. The key refers to an existing resource in a ResourceDictionary. 

Property Value

The locally applied style for the element, if present. Otherwise, a null reference (Nothing in Visual Basic). The default for a default-constructed FrameworkElement is a null reference (Nothing in Visual Basic).

Identifier field


Metadata properties set to true


For controls, the current style is often provided by an implicit style from control theming, or from styles generally applied to controls of that type by your application's resources. This property will not set or return such theme styles. It will only locally set the style, and return the style values that were locally set.

TSetting the styles has some restrictions. You can reset the entire Style property to a new Style at any time, which will force a layout recomposition. However, as soon as that style is in use by a loaded element, the Style in use should be considered sealed. Attempting to make a change to any individual property of an in-use style (such as anything within the collection of Setters) will raise an exception.

Style is a dependency property with special precedence. The locally set style operates at the highest precedence in the property system (with exception of animations, and animating a style is an advanced scenario). Therefore, if you set the Style property, that style will apply and will have higher precedence than implicit styles. See Dependency Property Value Precedence.

The following example defines a style in a resource dictionary.



  <Style TargetType="Border" x:Key="PageBackground">
    <Setter Property="Background" Value="Blue"/>


  <Border Style="{StaticResource PageBackground}">



Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions