Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-create-a-style-for-a-dragged-gridview-column-header.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

3.5 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Create a Style for a Dragged GridView Column Header 03/30/2017
ListView controls [WPF], styling
0b999645-0313-4b33-80b9-19ece08b5459

How to: Create a Style for a Dragged GridView Column Header

This example shows how to change the appearance of a dragged xref:System.Windows.Controls.GridViewColumnHeader when the user changes the position of a column.

Example

When you drag a column header to another location in a xref:System.Windows.Controls.ListView that uses xref:System.Windows.Controls.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 xref:System.Windows.Controls.GridView is represented by a xref:System.Windows.Controls.GridViewColumnHeader object.

To customize the appearance of both the floating and original headers, you can set xref:System.Windows.Controls.ControlTemplate.Triggers%2A to modify the xref:System.Windows.Controls.GridViewColumnHeader xref:System.Windows.Style. These xref:System.Windows.Controls.ControlTemplate.Triggers%2A are applied when the xref:System.Windows.Controls.Primitives.ButtonBase.IsPressed%2A property value is true and the xref:System.Windows.Controls.GridViewColumnHeader.Role%2A property value is xref:System.Windows.Controls.GridViewColumnHeaderRole.Floating.

When the user presses the mouse button and holds it down while the mouse pauses on the xref:System.Windows.Controls.GridViewColumnHeader, the xref:System.Windows.Controls.Primitives.ButtonBase.IsPressed%2A property value changes to true. Likewise, when the user begins the drag operation, the xref:System.Windows.Controls.GridViewColumnHeader.Role%2A property changes to xref:System.Windows.Controls.GridViewColumnHeaderRole.Floating.

The following example shows how to set xref:System.Windows.Controls.ControlTemplate.Triggers%2A to change the xref:System.Windows.Controls.Control.Foreground%2A and xref:System.Windows.Controls.Control.Background%2A colors of the original and floating headers when the user drags a column to a new position.

[!code-xamlListViewHeaderRoleStyle#GVCHControlTemplateStart]
[!code-xamlListViewHeaderRoleStyle#ControlTemplateTriggersStart]
[!code-xamlListViewHeaderRoleStyle#IsPressed]
[!code-xamlListViewHeaderRoleStyle#Floating]
[!code-xamlListViewHeaderRoleStyle#ControlTemplateTriggersEnd]
[!code-xamlListViewHeaderRoleStyle#GVCHControlTemplateEnd]

See also