次の方法で共有


ContentPresenter.ContentSource プロパティ

定義

自動エイリアシング時に使用するベース名を取得または設定します。

public:
 property System::String ^ ContentSource { System::String ^ get(); void set(System::String ^ value); };
public string ContentSource { get; set; }
member this.ContentSource : string with get, set
Public Property ContentSource As String

プロパティ値

自動エイリアシング時に使用するベース名。 既定値は "Content" です。

次の例は、ContentSource プロパティの使用方法を示すHeaderedContentControlのスタイルを示しています。

<Style TargetType="HeaderedContentControl">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type HeaderedContentControl}">
        <StackPanel>
          <Grid>
            <Rectangle Stroke="{TemplateBinding Background}"/>
            <ContentPresenter ContentSource="Header"/>
          </Grid>
          <Grid>
            <Rectangle Fill="{TemplateBinding Background}"/>
            <ContentPresenter ContentSource="Content"/>
          </Grid>
        </StackPanel>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

注釈

このプロパティは、 ContentPresenter がテンプレート内にある場合にのみ使用してください。 ContentSourceが "Abc" に設定されたContentPresenterがテンプレートに含まれている場合、ContentPresenterContentContentTemplate、およびContentTemplateSelectorプロパティはそれぞれ、AbcAbcTemplate、およびAbcTemplateSelectorに自動的にエイリアス化されます。 .NET Framework 3.5 Service Pack 1 以降では、 ContentSource を "Abc" に設定すると、 ContentStringFormat プロパティも AbcStringFormat にエイリアス化されます。

このプロパティに最も役立つ 2 つの値は、"Content" と "Header" です。

依存関係プロパティ情報

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

適用対象