RelativeSource.TemplatedParent 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
모드에 대해 TemplatedParent 생성된 값을 반환 RelativeSource 하는 데 사용되는 정적 값을 가져옵니다.
public:
static property System::Windows::Data::RelativeSource ^ TemplatedParent { System::Windows::Data::RelativeSource ^ get(); };
public static System.Windows.Data.RelativeSource TemplatedParent { get; }
static member TemplatedParent : System.Windows.Data.RelativeSource
Public Shared ReadOnly Property TemplatedParent As RelativeSource
속성 값
정적 RelativeSource.
예제
다음 예제에서는 호출 NumericUpDown된 Style 사용자 지정 컨트롤의 정의를 보여 있습니다. 이 Text 경우 적용되는 컨트롤인 개체의 속성 TextBlock 이 개체TemplatedParent의 NumericUpDown 속성 Style 에 바인딩 Value 됩니다.
<!--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>
설명
4개의 RelativeSourceMode 값 중 3개(Self또는TemplatedParent)는 고유한 프라이빗 값PreviousData이 없는 정적 값을 생성 RelativeSource 할 수 있습니다. 정적 속성의 모든 사용은 동일한 개체를 공유할 수 있으므로 각 용도에 대해 별도의 개체를 할당할 필요가 없습니다. 따라서 정적 속성을 사용하면 메모리 사용량이 줄어듭니다.
XAML 텍스트 사용
XAML 정보는 RelativeSource MarkupExtension을 참조하세요.