TabControl.SelectedContentTemplateSelector プロパティ

定義

現在選択されている項目の DataTemplateSelector を取得します。

public:
 property System::Windows::Controls::DataTemplateSelector ^ SelectedContentTemplateSelector { System::Windows::Controls::DataTemplateSelector ^ get(); };
public System.Windows.Controls.DataTemplateSelector SelectedContentTemplateSelector { get; }
member this.SelectedContentTemplateSelector : System.Windows.Controls.DataTemplateSelector
Public ReadOnly Property SelectedContentTemplateSelector As DataTemplateSelector

プロパティ値

現在選択されている項目の DataTemplateSelector。 既定値は、null です。

次の例では、 の を ControlTemplate 作成します TabControl。 プロパティを ContentSource に設定すると"SelectedContent"、および の各プロパティに対するSelectedContentSelectedContentTemplateエイリアスがSelectedContentTemplateSelector作成されます。

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

次の例では、SelectedContentTemplateSelectorTemplateBinding マークアップ拡張機能ContentPresenter.ContentTemplateSelector使用して プロパティを プロパティにバインドします。

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

注釈

では、TabControlタブの選択が変更されたときに、アクティブな TabItem の を参照するようにDataTemplateSelectorこのプロパティを更新します。 の または プロパティを設定TabControl.ContentTemplateSelectorして、 の TabItemDataTemplateSelector指定ContentTemplateSelectorします。TabItem

TabControl ではControlTemplate、 プロパティをContentPresenter.ContentSource使用して、 プロパティをContentPresenter.ContentTemplateSelectorこのプロパティにバインドします。 のTabControlControlTemplateしい を作成する場合は、 プロパティを "SelectedContent" に設定ContentPresenter.ContentSourceするか、TemplateBinding Markup Extension を使用して、 プロパティをこのプロパティにバインドContentPresenter.Contentしてください。

XAML 属性の使用方法

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

依存プロパティ情報

識別子フィールド SelectedContentTemplateSelectorProperty
に設定されたメタデータ プロパティ true なし

適用対象