Bagikan melalui


ContentPresenter.ContentSource Properti

Definisi

Mendapatkan atau mengatur nama dasar yang akan digunakan selama alias otomatis.

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

Nilai Properti

Nama dasar yang digunakan selama alias otomatis. Defaultnya adalah "Konten".

Contoh

Contoh berikut menunjukkan gaya untuk yang HeaderedContentControl menunjukkan penggunaan ContentSource properti:

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

Keterangan

Properti ini hanya boleh digunakan ketika ContentPresenter berada dalam templat. Saat templat berisi dengan ContentSource diatur ContentPresenter ke "Abc", Contentproperti , , ContentTemplatedan ContentTemplateSelector secara ContentPresenter otomatis di-alias ke Abc, AbcTemplate, dan AbcTemplateSelector, masing-masing. Dimulai dengan .NET Framework 3.5 Service Pack 1, pengaturan ContentSource ke "Abc" juga menyebabkan ContentStringFormat properti di-alias ke AbcStringFormat.

Dua nilai yang paling berguna untuk properti ini adalah "Konten" dan "Header".

Informasi Properti Dependensi

Item Nilai
Bidang pengidentifikasi ContentSourceProperty
Properti metadata diatur ke true Tidak

Berlaku untuk