New to Telerik UI for WinUIStart a free 30-day trial

ColumnHeaderTap Command

Updated on Mar 26, 2026

The ColumnHeaderTap command handles the tap gesture over a column header. The default implementation of this command will try to add a new SortDescriptor to the SortDescriptors collection of the DataGrid thus changing the current sorting of the data.

Execution Parameter

The execution parameter is of type ColumnHeaderTapContext and exposes the following properties:

  • Column—Gets or sets the DataGridColumn instance when the header is tapped.
  • CanSort—Determines whether the user is allowed to sort the data through the UI (as specified by the RadDataGrid.UserSortMode property).
  • IsMultipleSortAllowed—Determines whether any existing sort will be cleared before new sort is applied (if any).

Custom ColumnHeaderTap Command

The following examples show how to create a class that inherits from the DataGridCommand and then add it to the Commands collection.

Create a Custom ColumnHeaderTap Command

C#
public class CustomColumnHeaderTapCommand : DataGridCommand
{
	public CustomColumnHeaderTapCommand()
	{
		this.Id = CommandId.ColumnHeaderTap;
	}

	public override bool CanExecute(object parameter)
	{
		var context = parameter as ColumnHeaderTapContext;
		// put your custom logic here
		return true;
	}

	public override void Execute(object parameter)
	{
		var context = parameter as ColumnHeaderTapContext;
		// put your custom logic here   

		this.Owner.CommandService.ExecuteDefaultCommand(CommandId.ColumnHeaderTap, context);            
	}
}

Add the Custom Command to the Commands Collection

XAML
<Grid xmlns:grid="using:Telerik.UI.Xaml.Controls.Grid">
	<grid:RadDataGrid Width="600" Height="460" x:Name="grid">
		<grid:RadDataGrid.Commands>
			<local:CustomColumnHeaderTapCommand/>
		</grid:RadDataGrid.Commands>
	</grid:RadDataGrid>
</Grid>

See Also