GridViewColumn.CellTemplate 屬性

定義

取得或設定用來顯示資料行儲存格內容的範本。

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

屬性值

DataTemplate

DataTemplate,用於格式化資料行儲存格。 預設為 null

範例

下列範例示範如何指定要 DataTemplate 用來顯示 的 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}"/>

備註

下列屬性都會系結至資料行資料格的內容,並依優先順序列于此處,從最高到最低:

XAML Attribute Usage

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

XAML 屬性項目用法

XAML 值

ResourceExtension
下列其中一項: StaticResource 、 或 DynamicResource 。 請參閱 XAML 資源

TemplateResourceKey
識別所要求範本的索引鍵。 索引鍵是指 中的 ResourceDictionary 現有資源。

注意

屬性元素語法在技術上是可行的,但不建議使用。 請參閱 內嵌樣式和範本。 您也可以使用 或 的系結參考,但並不常見。

相依性屬性資訊

識別碼欄位 CellTemplateProperty
中繼資料屬性設定為 true

適用於

另請參閱