GridViewColumn.CellTemplate Property

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

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public DataTemplate CellTemplate { get; set; }
/** @property */
public DataTemplate get_CellTemplate ()

/** @property */
public void set_CellTemplate (DataTemplate value)

public function get CellTemplate () : DataTemplate

public function set CellTemplate (value : DataTemplate)

<object CellTemplate="{ResourceExtensionTemplateResourceKey}"/>
 ResourceExtension   StaticResource or DynamicResource. StaticResource typically provides better performance.  TemplateResourceKey  An x:Key resource key that refers to a template resource. 

Property Value

A DataTemplate that is used to format a column cell. The default value is a null reference (Nothing in Visual Basic).

Identifier field

CellTemplateProperty

Metadata properties set to true

None

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:

The following example shows how to specify a DataTemplate to use to display a GridViewColumn. For the complete sample, see ListView implementing a GridView with Templates.

<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"
      HeaderContainerStyle="{StaticResource myHeaderStyle}"
      HeaderTemplate="{StaticResource myHeaderTemplate}"
      DisplayMemberBinding="{Binding Path=Month}"/>

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: