ContentControl.ContentTemplate Properti

Definisi

Mendapatkan atau mengatur templat data yang digunakan untuk menampilkan konten ContentControl.

public:
 property System::Windows::DataTemplate ^ ContentTemplate { System::Windows::DataTemplate ^ get(); void set(System::Windows::DataTemplate ^ value); };
[System.ComponentModel.Bindable(true)]
public System.Windows.DataTemplate ContentTemplate { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.ContentTemplate : System.Windows.DataTemplate with get, set
Public Property ContentTemplate As DataTemplate

Nilai Properti

Templat data. Nilai defaultnya adalah null.

Atribut

Contoh

Contoh berikut menunjukkan cara membuat templat konten dan menerapkan templat ke kontrol konten.

<DataTemplate x:Key="template1">
  <TextBlock Text="{Binding}" FontSize="12" FontWeight="Bold" TextWrapping="Wrap"></TextBlock>
</DataTemplate>
<ContentControl Name="contCtrl" ContentTemplate="{StaticResource template1}" 
    Content="This is the content of the content control."/>

Keterangan

Atur properti ini ke DataTemplate untuk menentukan tampilan ContentControl. Untuk informasi selengkapnya tentang templat data, lihat Gambaran Umum Templat Data.

Penggunaan Atribut XAML

<object ContentTemplate="{resourceExtension styleResourceKey}"/>

Nilai XAML

resourceExtension Ekstensi markup yang mengidentifikasi cara mereferensikan sumber daya templat, baik StaticResource atau DynamicResource. Lihat Sumber Daya XAML.

styleResourceKey Kunci yang mengidentifikasi pemilih templat yang diminta. Kunci mengacu pada sumber daya yang ada dalam ResourceDictionary.

Note

Sintaks elemen properti secara teknis dimungkinkan, tetapi tidak disarankan. Untuk informasi selengkapnya, lihat Gaya dan Templat Sebaris.

Informasi Properti Dependensi

Item Nilai
Bidang pengidentifikasi ContentTemplateProperty
Properti metadata diatur ke true Tidak

Berlaku untuk