New to Telerik UI for WinUI? Download free 30-day trial

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 RadDataGrid, 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 which header has been 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

Examples 1 and 2 show how to create a class that inherits from the DataGridCommand and then add it to the Commands collection.

Example 1: Creating a custom ColumnHeaderTap Command

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);             
    } 
} 

Example 2: Adding the custom Command to the Commands collection

<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

In this article
Not finding the help you need?