Setter Class
Collapse the table of content
Expand the table of content

Setter Class


Represents a setter that applies a property value.

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

public class Setter : SetterBase, ISupportInitialize


Initializes a new instance of the Setter class.

System_CAPS_pubmethodSetter(DependencyProperty, Object)

Initializes a new instance of the Setter class with the specified property and value.

System_CAPS_pubmethodSetter(DependencyProperty, Object, String)

Initializes a new instance of the Setter class with the specified property, value, and target name.


Gets a value that indicates whether this object is in an immutable state.(Inherited from SetterBase.)


Gets or sets the property to which the Value will be applied.


Gets or sets the name of the object this Setter is intended for.


Gets or sets the value to apply to the property that is specified by this Setter.


Checks whether this object is read-only and cannot be changed.(Inherited from SetterBase.)


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticReceiveMarkupExtension(Object, XamlSetMarkupExtensionEventArgs)

Handles cases where a markup extension provides a value for a property of Setter object.

System_CAPS_pubmethodSystem_CAPS_staticReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs)

Handles cases where a type converter provides a value for a property of a Setter object.


Returns a string that represents the current object.(Inherited from Object.)


This API supports the product infrastructure and is not intended to be used directly from your code. Signals the object that initialization is starting.


This API supports the product infrastructure and is not intended to be used directly from your code. Signals the object that initialization is complete.

Exception Condition

The Property property cannot be null.


If the specified Property is a read-only property.


If the specified Value is set to UnsetValue.

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.

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" />

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">
    <Trigger Property="IsPressed" Value="true">
        <Setter Property = "Foreground" Value="Green"/>

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0

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

Return to top
© 2015 Microsoft