Style Property

FrameworkContentElement.Style Property

Gets or sets the style to be used by this element. 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)

    <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 style for the element.

Identifier field


Metadata properties set to true


Setting 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, once 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. See Dependency Property Value Precedence.

The following example establishes a Resources collection on a FlowDocument root element and then references it as a resource as a specific style for a Paragraph.

  x:Class=" SDKSample.Page2">
    <Style TargetType="{x:Type Paragraph}" x:Key="BluePara">
      <Setter Property="Background" Value="Blue"/>
      <Setter Property="FontSize" Value="18"/>
      <Setter Property="Foreground" Value="LightBlue"/>
      <Setter Property="FontFamily" Value="Trebuchet MS"/>
  <Paragraph Style="{StaticResource BluePara}">Lorem ipsum etc.</Paragraph>

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

© 2016 Microsoft