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

CellHolding Command

Handles the hold gesture on a grid cell. The default implementation will attempt to execute the CellFlyoutAction command for the specified cell.

Execution Parameter

The execution parameter is of type CellHoldingContext which exposes the following properties:

  • HoldingState: Gets the HoldingState reported from the Holding event.
  • CellInfo: Gets the DataGridCellInfo instance that this cell is associated with, giving access to its column and data item.

Custom CellFlyoutAction Command

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

Example 1: Creating a custom CellHolding Command

public class CustomCellHoldingCommand : DataGridCommand 
{ 
    public CustomCellHoldingCommand() 
    { 
        this.Id = CommandId.CellHolding; 
    } 
 
    public override bool CanExecute(object parameter) 
    { 
        var context = parameter as CellHoldingContext; 
        // put your custom logic here 
        return true; 
    } 
 
    public override void Execute(object parameter) 
    { 
        var context = parameter as CellHoldingContext; 
        // put your custom logic here           
 
        this.Owner.CommandService.ExecuteDefaultCommand(CommandId.CellHolding, 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" Hold> 
        <grid:RadDataGrid.Commands> 
            <local:CustomCellHoldingCommand/> 
        </grid:RadDataGrid.Commands> 
    </grid:RadDataGrid> 
</Grid> 

See Also

In this article
Not finding the help you need?