Cette documentation est archivée et n’est pas conservée.

FrameworkElement.Style, propriété

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

Espace de noms: System.Windows
Assembly : PresentationFramework (dans presentationframework.dll)
Espace de noms XML :  http://schemas.microsoft.com/winfx/2006/xaml/presentation

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. 

Valeur de la propriété

The locally applied style for the element, if present. Otherwise, référence Null (Nothing en Visual Basic). The default for a default-constructed FrameworkElement is référence Null (Nothing en Visual Basic).

Identifier field

StyleProperty

Metadata properties set to true

AffectsMeasure

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.

	<Page.Resources>
...

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

    <Border Style="{StaticResource PageBackground}">
...

	  </Border>

Microsoft .NET Framework 3.0 est pris en charge sur Windows Vista, Microsoft Windows XP SP2 et Windows Server 2003 SP1.

.NET Framework

Prise en charge dans : 3.0
Afficher: