Setter.Value 속성

정의

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.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)]
[System.Windows.Markup.DependsOn("Property")]
[System.Windows.Markup.DependsOn("TargetName")]
[System.ComponentModel.TypeConverter(typeof(System.Windows.Markup.SetterTriggerConditionValueConverter))]
public object Value { get; set; }
[<System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)>]
[<System.Windows.Markup.DependsOn("Property")>]
[<System.Windows.Markup.DependsOn("TargetName")>]
member this.Value : obj with get, set
[<System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)>]
[<System.Windows.Markup.DependsOn("Property")>]
[<System.Windows.Markup.DependsOn("TargetName")>]
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Markup.SetterTriggerConditionValueConverter))>]
member this.Value : obj with get, set
Public Property Value As Object

속성 값

기본값은 UnsetValue입니다.

특성

예외

지정된 ValueUnsetValue로 설정된 경우

예제

다음 예제에서는 모든 TextBlock 요소에 Style 적용할 를 정의합니다. 전체 예제는 스타일 지정 및 템플릿 샘플 소개를 참조하세요.

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

다음 예제에서는 시스템 리소스를 Style 참조하는 를 사용하여 Setter를 정의합니다.

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

다음 예제에서는 에 대 한 Style 를 정의 합니다 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>

다음 예제에서는 선언을 Value 사용 하는 속성입니다 Binding . 전체 예제는 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 특성 사용

<object Value="value"/>  

XAML 속성 요소 사용

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

XAML 값

value
개체 또는 태그 확장입니다. StaticResource 태그 확장을 참조하세요.

에 및 Value 속성을 Setter 모두 Property 지정해야 합니다. 그렇지 않으면 예외가 throw됩니다.

지정된 값이 개체인 경우 개체 내의 데이터 바인딩 및 동적 리소스가 Freezable 지원됩니다. 태그 확장 바인딩 및 DynamicResource 태그 확장을 참조하세요.

적용 대상

추가 정보