This documentation is archived and is not being maintained.

GridViewColumn Class

Updated: July 2008

Represents a column that displays data.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

[StyleTypedPropertyAttribute(Property = "HeaderContainerStyle", StyleTargetType = typeof(GridViewColumnHeader))]
[LocalizabilityAttribute(LocalizationCategory.None, Readability = Readability.Unreadable)]
public class GridViewColumn : DependencyObject, 

A GridViewColumn is used by the GridView view mode to display a column of data. The ListView that implements the GridView view mode provides the data for the column. You use data binding to specify the data for the GridViewColumn.

You can use the DisplayMemberBinding property to define the data to display in a column. You can also define the data as part of a DataTemplate that is specified by the CellTemplate property. If different cells have different DataTemplate objects, the CellTemplateSelector property can specify a DataTemplateSelector. The following list shows the properties mentioned here, in their order of precedence from highest to lowest:

The GridViewColumn class also contains properties that you can use to define and customize the column header for the column. The Header property can define the content of the column header. Other properties such as HeaderTemplate and HeaderContainerStyle can also specify content and style for the column header. Some of these properties are also found on other classes such as the GridViewColumnHeader class. For more information about the properties that are used to define styles and templates for column headers, and for information about the order of precedence for these properties, see GridView Column Header Styles and Templates Overview.

The GridViewColumn class implements the INotifyPropertyChanged interface. This interface provides the ability to subscribe to the events that occur when a change occurs to a property value, such as the ActualWidth property value.

The following example shows how to define GridViewColumn objects for a GridView.

<ListView ItemsSource="{Binding Source={StaticResource EmployeeData}, 
      <GridViewColumn Header="First Name"
               DisplayMemberBinding="{Binding XPath=FirstName}" />
      <GridViewColumn Header="Last Name"  
               CellTemplate="{StaticResource LastNameCellTemplate}"/>
      <GridViewColumn Header="Favorite City" 

More Code

How to: Display ListView Contents by Using a GridView This example shows how to define a GridView view mode for a ListView control.
How to: Use Templates to Style a ListView That Uses GridView This example shows how to use the DataTemplate and Style objects to specify the appearance of a ListView control that uses a GridView view mode.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0




July 2008

Added new members: HeaderStringFormat property, HeaderStringFormatProperty field, OnHeaderStringFormatChanged method.

SP1 feature change.