Setter.Value 속성

정의

Setter에 지정된 속성에 적용할 값을 가져오거나 설정합니다.Gets or sets the value to apply to the property that is specified by this Setter.

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

속성 값

기본값은 UnsetValue입니다.The default value is UnsetValue.

특성

예외

지정된 ValueUnsetValue로 설정된 경우If the specified Value is set to UnsetValue.

예제

다음 예제에서는 모든 TextBlock 요소에 적용 되는 Style을 정의 합니다.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" />
</Style>

다음 예제에서는 시스템 리소스를 참조 하는 Setter를 사용 하 여 Style를 정의 합니다.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}}"/>
</Style>

다음 예에서는 RepeatButton에 대 한 Style를 정의 합니다.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">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Thumb}">
                <Grid Width="14" Height="14">
                    <Ellipse Fill="{TemplateBinding Foreground}" />
                    <Ellipse Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" x:Name="ThumbCover" >
                        <Ellipse.Fill>
                            <LinearGradientBrush  EndPoint="0,1" StartPoint="0,0">
                                <LinearGradientBrush.GradientStops>
                                    <GradientStop Color="#CCFFFFFF" Offset="0" />
                                    <GradientStop Color="#00000000" Offset=".5" />
                                    <GradientStop Color="#66000000" Offset="1" />
                                </LinearGradientBrush.GradientStops>
                            </LinearGradientBrush>
                        </Ellipse.Fill>
                    </Ellipse>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsDragging" Value="true">
                        <Setter TargetName="ThumbCover" Property="Fill">
                            <Setter.Value>
                                <LinearGradientBrush  EndPoint="0,1" StartPoint="0,0">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#CCFFFFFF" Offset="1" />
                                        <GradientStop Color="#00000000" Offset=".5" />
                                        <GradientStop Color="#66000000" Offset="0" />
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

다음 예제에서는 Binding 선언을 사용 하는 Value 속성을 보여 줍니다.The following example shows a Value property that uses the Binding declaration. 전체 예제는 Binding Validation Sample(바인딩 유효성 검사 샘플)을 참조하세요.For the complete example, see Binding Validation Sample.

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

설명

XAML 특성 사용XAML Attribute Usage

<object Value="value"/>  

XAML 속성 요소 사용XAML Property Element Usage

<object>  
  <object.Value>  
    value  
  </object.Value>  
</object>  

XAML 값XAML Values

valuevalue
개체 또는 태그 확장 합니다.An object or a markup extension. StaticResource 태그 확장을 참조 하세요.See StaticResource Markup Extension.

Setter에서 PropertyValue 속성을 모두 지정 해야 합니다. 그렇지 않으면 예외가 throw 됩니다.Note that you must specify both the Property and Value properties on a Setter or an exception will be thrown.

지정 된 값이 Freezable 개체인 경우 개체 내의 데이터 바인딩 및 동적 리소스가 지원 됩니다.Data binding and dynamic resources within the object is supported if the specified value is a Freezable object. Binding 태그 확장DynamicResource 태그 확장을 참조 하세요.See Binding Markup Extension and DynamicResource Markup Extension.

적용 대상

추가 정보