ContentPresenter.ContentSource Właściwość

Definicja

Pobiera lub ustawia nazwę podstawową do użycia podczas automatycznego aliasowania.

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

Wartość właściwości

String

Nazwa podstawowa do użycia podczas automatycznego aliasowania. Wartość domyślna to "Zawartość".

Przykłady

W poniższym przykładzie pokazano styl elementu HeaderedContentControl , który demonstruje użycie ContentSource właściwości:

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

Uwagi

Tej właściwości należy używać tylko wtedy, gdy ContentPresenter element znajduje się w szablonie. Gdy szablon zawiera element z ustawionym ContentPresenter na "Abc", Contentwłaściwości , ContentTemplatei ContentTemplateSelector klasy ContentPresenter są automatycznie aliasowane odpowiednio do Abc, AbcTemplatei AbcTemplateSelector.ContentSource Począwszy od .NET Framework 3.5 z dodatkiem Service Pack 1, ustawienie ContentSource "" powoduje ContentStringFormat również alias AbcStringFormat``Abcwłaściwości .

Dwie najbardziej przydatne wartości tej właściwości to "Zawartość" i "Nagłówek".

Informacje dotyczące właściwości zależności

Pole identyfikatora ContentSourceProperty
Właściwości metadanych ustawione na true Brak

Dotyczy