Setter.Value Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

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

[LocalizabilityAttribute(LocalizationCategory.None, Readability = Readability.Unreadable)]
public object Value { get; set; }

Property Value

Type: System.Object

The default value is UnsetValue.

Exception Condition

If the specified Value is set to UnsetValue.

<object Value="value"/>



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.

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.

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},

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top