Represents a setter that applies a property value.

Inheritance Hierarchy
Namespace:
System.Windows
Assembly:
PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

Syntax
<XamlSetMarkupExtensionAttribute("ReceiveMarkupExtension")> _
<XamlSetTypeConverterAttribute("ReceiveTypeConverter")> _
Public Class Setter _
Inherits SetterBase _
Implements ISupportInitialize
[XamlSetMarkupExtensionAttribute("ReceiveMarkupExtension")]
[XamlSetTypeConverterAttribute("ReceiveTypeConverter")]
public class Setter : SetterBase, ISupportInitialize
[XamlSetMarkupExtensionAttribute(L"ReceiveMarkupExtension")]
[XamlSetTypeConverterAttribute(L"ReceiveTypeConverter")]
public ref class Setter : public SetterBase,
ISupportInitialize
[<XamlSetMarkupExtensionAttribute("ReceiveMarkupExtension")>]
[<XamlSetTypeConverterAttribute("ReceiveTypeConverter")>]
type Setter =
class
inherit SetterBase
interface ISupportInitialize
end
XAML Object Element Usage
The Setter type exposes the following members.

Constructors

Methods

Explicit Interface Implementations

Exceptions

Remarks
Styles and the different types of triggers (classes that inherit from TriggerBase) use Setters to apply property values.
Note that you must specify both the Property and Value properties on a Setter for the setter to be meaningful. If one or both properties are not set, an exception will be thrown.

Examples
The following example defines a Style that will be applied to every TextBlock element. This Style applies values to several TextBlock properties with the use of Setters.
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="Segoe Black" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="FontSize" Value="12pt" />
<Setter Property="Foreground" Value="#777777" />
</Style>
The following example shows a named Style available to Button controls. The Style defines a Trigger element that changes the Foreground property of a button when the IsPressed property is true.
<Style x:Key="Triggers" TargetType="Button">
<Style.Triggers>
<Trigger Property="IsPressed" Value="true">
<Setter Property = "Foreground" Value="Green"/>
</Trigger>
</Style.Triggers>
</Style>

Version Information
.NET Framework
Supported in: 4, 3.5, 3.0
.NET Framework Client Profile
Supported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public
static (
Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also