Export (0) Print
Expand All

GridViewColumnHeader Class

Represents a column header for a GridViewColumn.

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

'Declaration
<TemplatePartAttribute(Name:="PART_HeaderGripper", Type:=GetType(Thumb))> _
<TemplatePartAttribute(Name:="PART_FloatingHeaderCanvas", Type:=GetType(Canvas))> _
Public Class GridViewColumnHeader
	Inherits ButtonBase
'Usage
Dim instance As GridViewColumnHeader

/** @attribute TemplatePartAttribute(Name="PART_HeaderGripper", Type=System.Windows.Controls.Primitives.Thumb) */ 
/** @attribute TemplatePartAttribute(Name="PART_FloatingHeaderCanvas", Type=System.Windows.Controls.Canvas) */ 
public class GridViewColumnHeader extends ButtonBase
TemplatePartAttribute(Name="PART_HeaderGripper", Type=System.Windows.Controls.Primitives.Thumb) 
TemplatePartAttribute(Name="PART_FloatingHeaderCanvas", Type=System.Windows.Controls.Canvas) 
public class GridViewColumnHeader extends ButtonBase
<GridViewColumnHeader>
  Content
</GridViewColumnHeader>

A GridViewColumnHeader object is a button control that is derived from ButtonBase. GridViewColumnHeader properties keep track of mouse events and the resizing of columns.

Column headers in a GridView view mode are GridViewColumnHeader objects.

You can customize GridViewColumnHeader objects by using a variety of properties that are found in this class and in related classes. For more information about these properties, and about the precedence between them, see GridView Column Header Styles and Templates Overview.

This example shows how to change the appearance of a dragged GridViewColumnHeader when the user changes the position of a column.

When you drag a column header to another location in a ListView that uses GridView for its view mode, the column moves to the new position. While you are dragging the column header, a floating copy of the header appears in addition to the original header. A column header in a GridView is represented by a GridViewColumnHeader object.

To customize the appearance of both the floating and original headers, you can set Triggers to modify the GridViewColumnHeader Style. These Triggers are applied when the IsPressed property value is true and the Role property value is Floating.

When the user presses the mouse button and holds it down while the mouse pauses on the GridViewColumnHeader, the IsPressed property value changes to true. Likewise, when the user begins the drag operation, the Role property changes to Floating.

The following example shows how to set Triggers to change the Foreground and Background colors of the original and floating headers when the user drags a column to a new position.

      <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">

...

        <ControlTemplate.Triggers>

...

        <Trigger Property="IsPressed"
                 Value="true">
          <Setter TargetName="HighlightBorder"
                  Property="Visibility"
                  Value="Hidden"/>
          <Setter TargetName="PART_HeaderGripper"
                  Property="Visibility"
                  Value="Hidden"/>
          <Setter Property="Background"
                  Value="SkyBlue"/>
          <Setter Property="Foreground"
                  Value="Yellow"/>
        </Trigger>

...

        <Trigger Property="Role"
                 Value="Floating">
          <Setter TargetName="PART_HeaderGripper"
                  Property="Visibility"
                  Value="Collapsed"/>
          <Setter Property="Background"
                  Value="Yellow"/>
          <Setter Property="Foreground"
                  Value="SkyBlue"/>
        </Trigger>

...

      </ControlTemplate.Triggers>

...

      </ControlTemplate>

For the complete sample, see ListView with Custom Floating Header Sample.

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Control
               System.Windows.Controls.ContentControl
                 System.Windows.Controls.Primitives.ButtonBase
                  System.Windows.Controls.GridViewColumnHeader

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

ADD
Show:
© 2014 Microsoft