Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

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)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
public DataTemplate CellTemplate { get; set; }
<object CellTemplate="{ResourceExtension TemplateResourceKey}"/>

XAML Values

ResourceExtension

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

TemplateResourceKey

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

NoteNote

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

Property Value

Type: System.Windows.DataTemplate
A DataTemplate that is used to format a column cell. The default is null.

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.


<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}"/>


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.