RelativeSource.TemplatedParent 속성

정의

RelativeSource 모드에 대해 생성된 TemplatedParent를 반환하는 데 사용되는 정적 값을 가져옵니다.

public:
 static property System::Windows::Data::RelativeSource ^ TemplatedParent { System::Windows::Data::RelativeSource ^ get(); };
public static System.Windows.Data.RelativeSource TemplatedParent { get; }
member this.TemplatedParent : System.Windows.Data.RelativeSource
Public Shared ReadOnly Property TemplatedParent As RelativeSource

속성 값

RelativeSource

정적 RelativeSource입니다.

예제

다음 예제는 Style 사용자 지정 컨트롤의 정의 NumericUpDown합니다. Text 의 속성을 TextBlock 바인딩되는 Value 되는 개체의는 TemplatedParentNumericUpDown 이 제어 Style 이 경우에 적용 됩니다.

<!--ControlTemplate for NumericUpDown that inherits from
    Control.-->
<Style TargetType="{x:Type local:NumericUpDown}">
  <Setter Property="HorizontalAlignment" Value="Center"/>
  <Setter Property="VerticalAlignment" Value="Center"/>
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type local:NumericUpDown}">
        <Grid Margin="3">
          <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
          </Grid.ColumnDefinitions>

          <Border BorderThickness="1" BorderBrush="Gray" 
                  Margin="2" Grid.RowSpan="2" 
                  VerticalAlignment="Center" HorizontalAlignment="Stretch">
                  
            <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" 
                       Width="60" TextAlignment="Right" Padding="5"/>
          </Border>
          
          <RepeatButton Command="{x:Static local:NumericUpDown.IncreaseCommand}"  
                        Grid.Column="1" Grid.Row="0">Up</RepeatButton>
                        
          <RepeatButton Command="{x:Static local:NumericUpDown.DecreaseCommand}"
                        Grid.Column="1" Grid.Row="1">Down</RepeatButton>

        </Grid>

      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

설명

네 가지 중 3 개 RelativeSourceMode 값을 PreviousData, Self, 또는 TemplatedParent를 생성할 수 있습니다를 RelativeSource 완전히 정적인 값이 없는 고유한 프라이빗입니다. 정적 속성의 모든 사용에는 각 사용에 대 한 별도 개체를 할당할 필요가 없도록 동일한 개체를 공유할 수 있습니다. 따라서 정적 속성을 사용 하 여 메모리 사용량을 줄입니다.

XAML 텍스트 사용

XAML 정보는 RelativeSource MarkupExtension을 참조하세요.

적용 대상

추가 정보