GridViewColumn.CellTemplate Properti

Definisi

Mendapatkan atau mengatur templat yang akan digunakan untuk menampilkan konten sel kolom.

public:
 property System::Windows::DataTemplate ^ CellTemplate { System::Windows::DataTemplate ^ get(); void set(System::Windows::DataTemplate ^ value); };
public System.Windows.DataTemplate CellTemplate { get; set; }
member this.CellTemplate : System.Windows.DataTemplate with get, set
Public Property CellTemplate As DataTemplate

Nilai Properti

Yang DataTemplate digunakan untuk memformat sel kolom. Defaultnya adalah null.

Contoh

Contoh berikut menunjukkan cara menentukan yang DataTemplate akan digunakan untuk menampilkan GridViewColumn.

<DataTemplate x:Key="myCellTemplateMonth">
  <DockPanel>
    <TextBlock Foreground="DarkBlue" HorizontalAlignment="Center">
      <TextBlock.Text>
        <Binding Path="Month"/>
      </TextBlock.Text>
    </TextBlock>
  </DockPanel>
</DataTemplate>
<GridViewColumn Header="Month" Width="80"
      CellTemplate="{StaticResource myCellTemplateMonth}"/>

Keterangan

Properti berikut semua terikat ke dan menampilkan konten sel kolom, dan tercantum di sini dalam urutan prioritasnya, dari tertinggi hingga terendah:

Penggunaan Atribut XAML

<object CellTemplate="{ResourceExtension TemplateResourceKey}"/>

Penggunaan Elemen Properti XAML

Nilai XAML

ResourceExtension Salah satu hal berikut: StaticResource, atau DynamicResource. Lihat Sumber Daya XAML.

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

Note

Sintaks elemen properti secara teknis dimungkinkan, tetapi tidak disarankan. Lihat Gaya dan Templat Sebaris. Referensi pengikatan menggunakan atau juga dimungkinkan, tetapi jarang.

Informasi Properti Dependensi

Item Nilai
Bidang pengidentifikasi CellTemplateProperty
Properti metadata diatur ke true Tidak

Berlaku untuk

Lihat juga