TabControl.SelectedContentTemplate Özellik

Tanım

DataTemplate Seçili durumdaki öğenin öğesini alır.

public:
 property System::Windows::DataTemplate ^ SelectedContentTemplate { System::Windows::DataTemplate ^ get(); };
public System.Windows.DataTemplate SelectedContentTemplate { get; }
member this.SelectedContentTemplate : System.Windows.DataTemplate
Public ReadOnly Property SelectedContentTemplate As DataTemplate

Özellik Değeri

DataTemplate Seçili öğenin öğesi.

Örnekler

Aşağıdaki örnek için ControlTemplatebir TabControl oluşturur. özelliğini ayarlayıp ContentSource"SelectedContent" , SelectedContentve SelectedContentTemplate özellikleri için SelectedContentTemplateSelectordiğer adlar oluşturur.

<Style  TargetType="{x:Type TabControl}">
  <Setter Property="OverridesDefaultStyle"
          Value="True" />
  <Setter Property="SnapsToDevicePixels"
          Value="True" />
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type TabControl}">
        <Grid KeyboardNavigation.TabNavigation="Local">
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
          </Grid.RowDefinitions>
          <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
              <VisualState x:Name="Disabled">
                <Storyboard>
                  <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                Storyboard.TargetProperty="(Border.BorderBrush).
                    (SolidColorBrush.Color)">
                    <EasingColorKeyFrame KeyTime="0"
                                         Value="#FFAAAAAA" />
                  </ColorAnimationUsingKeyFrames>
                </Storyboard>
              </VisualState>
            </VisualStateGroup>
          </VisualStateManager.VisualStateGroups>
          <TabPanel x:Name="HeaderPanel"
                    Grid.Row="0"
                    Panel.ZIndex="1"
                    Margin="0,0,4,-1"
                    IsItemsHost="True"
                    KeyboardNavigation.TabIndex="1"
                    Background="Transparent" />
          <Border x:Name="Border"
                  Grid.Row="1"
                  BorderThickness="1"
                  CornerRadius="2"
                  KeyboardNavigation.TabNavigation="Local"
                  KeyboardNavigation.DirectionalNavigation="Contained"
                  KeyboardNavigation.TabIndex="2">
            <Border.Background>
              <LinearGradientBrush EndPoint="0.5,1"
                                   StartPoint="0.5,0">
                <GradientStop Color="{DynamicResource ContentAreaColorLight}"
                              Offset="0" />
                <GradientStop Color="{DynamicResource ContentAreaColorDark}"
                              Offset="1" />
              </LinearGradientBrush>
            </Border.Background>
            <Border.BorderBrush>
              <SolidColorBrush Color="{DynamicResource BorderMediumColor}"/>
            </Border.BorderBrush>
            <ContentPresenter x:Name="PART_SelectedContentHost"
                              Margin="4"
                              ContentSource="SelectedContent" />
          </Border>
        </Grid>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

Aşağıdaki örnekSelectedContentTemplateContentPresenter.ContentTemplate kullanarak özelliğini özelliğine bağlar.

<ContentPresenter Content="{TemplateBinding SelectedContent}" 
     ContentTemplate="{TemplateBinding SelectedContentTemplate}" 
     ContentTemplateSelector="{TemplateBinding SelectedContentTemplateSelector}" />

Açıklamalar

Bu özellik, TabControl sekme seçimi değiştiğinde DataTemplate etkin TabItem için öğesine başvurmak üzere güncelleştirir. TabControl.ContentTemplate için öğesini belirtmek ContentTemplate için TabItemveya üzerinde DataTemplate özelliğini ayarlayınTabItem.

ControlTemplate özelliği TabControl özelliğini bu özelliğe bağlamak ContentPresenter.ContentSource için kullanırContentPresenter.ContentTemplate. için ControlTemplateyeni TabControl bir oluşturursanız, özelliğini "SelectedContent" olarak ayarlayarak ContentPresenter.Content veya ContentPresenter.ContentSource kullanarak özelliğini bu özelliğe bağladığınızdan emin olun.

XAML Öznitelik Kullanımı

<object property="{TemplateBinding SelectedContentTemplate}"/>

Bağımlılık Özelliği Bilgileri

Öğe Değer
Tanımlayıcı alanı SelectedContentTemplateProperty
Meta veri özellikleri olarak ayarlandı true Hiçbiri

Şunlara uygulanır