GridViewColumn Class
Updated: July 2008
Represents a column that displays data.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
'Declaration <StyleTypedPropertyAttribute(Property := "HeaderContainerStyle", StyleTargetType := GetType(GridViewColumnHeader))> _ <LocalizabilityAttribute(LocalizationCategory.None, Readability := Readability.Unreadable)> _ <ContentPropertyAttribute("Header")> _ Public Class GridViewColumn _ Inherits DependencyObject _ Implements INotifyPropertyChanged 'Usage Dim instance As GridViewColumn
<GridViewColumn> Header </GridViewColumn>
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},
XPath=Employee}">
<ListView.View>
<GridView>
<GridViewColumn Header="First Name"
DisplayMemberBinding="{Binding XPath=FirstName}" />
<GridViewColumn Header="Last Name"
CellTemplate="{StaticResource LastNameCellTemplate}"/>
<GridViewColumn Header="Favorite City"
CellTemplateSelector="{DynamicResource
FavoriteCityTemplateSelector}"/>
</GridView>
</ListView.View>
</ListView>
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. |
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Controls.GridViewColumn
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.
Date | History | Reason |
|---|---|---|
July 2008 | Added new members: HeaderStringFormat property, HeaderStringFormatProperty field, OnHeaderStringFormatChanged method. | SP1 feature change. |