Setter.Value Property


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

 property System::Object ^ Value { System::Object ^ get(); void set(System::Object ^ value); };
[System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)]
public object Value { get; set; }
member this.Value : obj with get, set
Public Property Value As Object

Property Value

The default value is UnsetValue.



If the specified Value is set to UnsetValue.


The following example defines a Style that will be applied to every TextBlock element. For the complete example, see Introduction to Styling and Templating Sample.

<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 defines a Style with Setters that reference system resources.

<Style x:Key="SystemResStyle" TargetType="{x:Type Button}">
    <Setter Property = "Background" Value= 
                       "{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"/>
    <Setter Property = "Foreground" Value= 
                       "{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>
    <Setter Property = "FontSize" Value= 
                       "{DynamicResource {x:Static SystemFonts.IconFontSizeKey}}"/>
    <Setter Property = "FontWeight" Value= 
                       "{DynamicResource {x:Static SystemFonts.MessageFontWeightKey}}"/>
    <Setter Property = "FontFamily" Value= 
                       "{DynamicResource {x:Static SystemFonts.CaptionFontFamilyKey}}"/>

The following example defines a Style for the RepeatButton.

<Style x:Key="Slider_Thumb" TargetType="{x:Type Thumb}">
    <Setter Property="OverridesDefaultStyle" Value="true" />
    <Setter Property="Width" Value="14" />
    <Setter Property="Height" Value="14" />
    <Setter Property="Template">
            <ControlTemplate TargetType="{x:Type Thumb}">
                <Grid Width="14" Height="14">
                    <Ellipse Fill="{TemplateBinding Foreground}" />
                    <Ellipse Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" x:Name="ThumbCover" >
                            <LinearGradientBrush  EndPoint="0,1" StartPoint="0,0">
                                    <GradientStop Color="#CCFFFFFF" Offset="0" />
                                    <GradientStop Color="#00000000" Offset=".5" />
                                    <GradientStop Color="#66000000" Offset="1" />
                    <Trigger Property="IsDragging" Value="true">
                        <Setter TargetName="ThumbCover" Property="Fill">
                                <LinearGradientBrush  EndPoint="0,1" StartPoint="0,0">
                                        <GradientStop Color="#CCFFFFFF" Offset="1" />
                                        <GradientStop Color="#00000000" Offset=".5" />
                                        <GradientStop Color="#66000000" Offset="0" />

The following example shows a Value property that uses the Binding declaration. For the complete example, see Binding Validation Sample.

<Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
    <Trigger Property="Validation.HasError" Value="true">
      <Setter Property="ToolTip"
        Value="{Binding RelativeSource={x:Static RelativeSource.Self},


XAML Attribute Usage

<object Value="value"/>  

XAML Property Element Usage


XAML Values

An object or a markup extension. See StaticResource Markup Extension.

Note that you must specify both the Property and Value properties on a Setter or an exception will be thrown.

Data binding and dynamic resources within the object is supported if the specified value is a Freezable object. See Binding Markup Extension and DynamicResource Markup Extension.

Applies to

See also