Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GridViewColumn Class

Represents a column that displays data.

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

[StyleTypedPropertyAttribute(Property="HeaderContainerStyle", StyleTargetType=typeof(GridViewColumnHeader))] 
[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)] 
[ContentPropertyAttribute("Header")] 
public class GridViewColumn : DependencyObject, INotifyPropertyChanged
/** @attribute StyleTypedPropertyAttribute(Property="HeaderContainerStyle", StyleTargetType=System.Windows.Controls.GridViewColumnHeader) */ 
/** @attribute LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) */ 
/** @attribute ContentPropertyAttribute("Header") */ 
public class GridViewColumn extends DependencyObject implements INotifyPropertyChanged
StyleTypedPropertyAttribute(Property="HeaderContainerStyle", StyleTargetType=System.Windows.Controls.GridViewColumnHeader) 
LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) 
ContentPropertyAttribute("Header") 
public class GridViewColumn extends DependencyObject implements INotifyPropertyChanged
<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:

  • DisplayMemberBinding

  • CellTemplate

  • CellTemplateSelector

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 TemplatesOverview.

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.

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 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

Community Additions

Show:
© 2014 Microsoft