TemplateBindingExtension 클래스

정의

템플릿의 속성 값과 템플릿 컨트롤에 있는 기타 노출된 일부 속성의 값 간에 바인딩을 지원하는 태그 확장을 구현합니다.

public ref class TemplateBindingExtension : System::Windows::Markup::MarkupExtension
[System.ComponentModel.TypeConverter(typeof(System.Windows.TemplateBindingExtensionConverter))]
public class TemplateBindingExtension : System.Windows.Markup.MarkupExtension
[System.ComponentModel.TypeConverter(typeof(System.Windows.TemplateBindingExtensionConverter))]
[System.Windows.Markup.MarkupExtensionReturnType(typeof(System.Object))]
public class TemplateBindingExtension : System.Windows.Markup.MarkupExtension
[<System.ComponentModel.TypeConverter(typeof(System.Windows.TemplateBindingExtensionConverter))>]
type TemplateBindingExtension = class
    inherit MarkupExtension
[<System.ComponentModel.TypeConverter(typeof(System.Windows.TemplateBindingExtensionConverter))>]
[<System.Windows.Markup.MarkupExtensionReturnType(typeof(System.Object))>]
type TemplateBindingExtension = class
    inherit MarkupExtension
Public Class TemplateBindingExtension
Inherits MarkupExtension
상속
TemplateBindingExtension
특성

예제

다음 예제에서는 가로이고 모서리가 둥근 값을 정의하는 ListBox 방법을 보여 ControlTemplate 줍니다. 의 TemplateBinding 값이 Background Border 에 설정된 값과 Background 동기화되어야 했음을 ListBox나타냅니다. 컨트롤의 사용자에게 특정 속성의 값을 제어할 수 있도록 하려는 경우에 사용합니다 TemplateBinding ControlTemplate . 이 예제에 대한 자세한 내용은 스타일 지정 및 템플릿을 참조하세요.

<Style TargetType="ListBox">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="ListBox">
        <Border CornerRadius="5" Background="{TemplateBinding ListBox.Background}">
          <ScrollViewer HorizontalScrollBarVisibility="Auto">
            <StackPanel Orientation="Horizontal"
                       VerticalAlignment="Center"
                       HorizontalAlignment="Center"
                       IsItemsHost="True"/>
          </ScrollViewer>
        </Border>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

다음 예제에서는 컨트롤의 ControlTemplate 입니다 Label . 및 속성이 HorizontalAlignment 적용되는 컨트롤 ControlTemplateHorizontalContentAlignment 값과 VerticalContentAlignment 속성에 Label 바인딩 VerticalAlignment 됩니다.

<Style x:Key="{x:Type Label}"
       TargetType="Label">
  <Setter Property="HorizontalContentAlignment"
          Value="Left" />
  <Setter Property="VerticalContentAlignment"
          Value="Top" />
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="Label">
        <Border>
          <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            RecognizesAccessKey="True" />
        </Border>
        <ControlTemplate.Triggers>
          <Trigger Property="IsEnabled"
                   Value="false">
            <Setter Property="Foreground">
              <Setter.Value>
                <SolidColorBrush Color="{DynamicResource DisabledForegroundColor}" />
              </Setter.Value>
            </Setter>
          </Trigger>
        </ControlTemplate.Triggers>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

설명

템플릿에서 템플릿이 적용되는 컨트롤의 값에 바인딩하는 데 사용합니다 TemplateBinding . A TemplateBinding 는 a Binding 보다 효율적이지만 기능이 적습니다. a를 TemplateBinding 사용하는 것은 속성이 .로 설정된 a BindingRelativeSource 사용하는 것과 RelativeSource.TemplatedParent같습니다.

XAML 텍스트 사용

XAML 정보는 TemplateBinding 태그 확장을 참조하세요.

생성자

TemplateBindingExtension()

TemplateBindingExtension 클래스의 새 인스턴스를 초기화합니다.

TemplateBindingExtension(DependencyProperty)

바인딩의 소스인 지정된 종속성 속성을 사용하여 TemplateBindingExtension 클래스의 새 인스턴스를 초기화합니다.

속성

Converter

바인딩 소스와 대상 간을 해석하는 변환기를 가져오거나 설정합니다.

ConverterParameter

변환기로 전달할 매개 변수를 가져오거나 설정합니다.

Property

바인딩 대상 속성을 가져오거나 설정합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ProvideValue(IServiceProvider)

이 태그 확장의 대상 개체 속성에 대한 값으로 설정해야 하는 개체를 반환합니다. TemplateBindingExtension의 경우 바인딩을 지원하는 식(TemplateBindingExpression)입니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상