Share via

GridViewColumn.CellTemplate Property


Gets or sets the template to use to display the contents of a column cell.

 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

Property Value

A DataTemplate that is used to format a column cell. The default is null.


The following example shows how to specify a DataTemplate to use to display a GridViewColumn.

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


The following properties all bind to and display the content of a column cell, and are listed here in their order of precedence, from highest to lowest:

XAML Attribute Usage

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

XAML Property Element Usage

XAML Values

One of the following: StaticResource, or DynamicResource. See XAML Resources.

The key that identifies the template being requested. The key refers to an existing resource in a ResourceDictionary.


Property element syntax is technically possible, but not recommended. See Inline Styles and Templates. A binding reference using or is also possible, but uncommon.

Dependency Property Information

Identifier field CellTemplateProperty
Metadata properties set to true None

Applies to

See also