Overview

RadVirtualGrid provides a set of built-in commands that enables you to easily handle the user interface actions, but still make your logic independent of the UI layout. Thus, you are not obliged to subscribe to a particular event in order to achieve the desired behavior.

All supported commands are defined in the RadVirtualGridCommands class and are listed below:

Telerik UI for WPF Ninja image

The Commands is part of Telerik UI for WPF, a professional grade UI library with 160+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.

  • CommitEdit: Forces all the changes to be committed.

  • BeginEdit: Invokes editing of the current cell.

  • BeginInsert: Starts the process of inserting a new row.

  • CancelEdit: Causes the editing of the current cell to be stopped and the changes to be discarded.

  • SelectAll: Selects all elements.

  • Copy: Copies the selected data to the Clipboard.

  • Delete: Deletes the elements present in the SelectedIndexes collection.

  • MoveLeft, MoveRight: Moves the focus to the cell situated in the left/right side of the selected one.

  • MoveUp, MoveDown: Moves the focus to the cell situated above/below the selected one.

  • MoveNext, MovePrevious: Moves the focus to the next/ previous cell. Once the first/last cell on the row is reached, it will jump to the cell in the previous/ next row.

  • MoveFirst, MoveLast: Moves the focus to the first/last cell situated in the current item.

  • MoveHome, MoveEnd: Moves the focus to the first cell of the first item or last cell of last item, respectively.

  • MovePageUp, MovePageDown: Moves the focus to the cell situated one viewport away from the current cell.

  • MoveTop, MoveBottom: Moves the focus to the cell situated in the first/last item.

  • PinRowTop, PinRowBottom: Pins a row at the top/bottom.

  • PinColumnLeft, PinColumnRight: Pins a column to the left/right.

  • UnpinRow, UnpinColumn: Unpins a row/column.

  • SelectCurrentUnit: Selects the current unit. By default the selection unit is "Row", but the SelectionUnit property may also be set to "Cell", thus enabling a cell-based selection.

  • ExtendSelectionToCurrentUnit: Selects all the selection unit from the anchor up to the chosen unit.

As the commands provided by RadVirtualGrid are ICommands at their core, they do provide methods for both checking if they can be invoked - CanExecute() and for invoking them - Execute().

Example 1: Executing different commands

private void Button1_Click(object sender, RoutedEventArgs e) 
{ 
    var moveDownCommand = RadVirtualGridCommands.MoveDown as RoutedUICommand; 
    var selectCommand = RadVirtualGridCommands.SelectCurrentUnit as RoutedUICommand; 
    var deleteCommand = RadVirtualGridCommands.Delete as RoutedUICommand; 
    moveDownCommand.Execute(null, this.VirtualGrid); 
    selectCommand.Execute(null, this.VirtualGrid); 
    deleteCommand.Execute(null, this.VirtualGrid); 
} 

In order to ensure that all commands will be executed in the correct sequence, it is advised to use RadVirtualGrid's PendingCommands collection as demonstrated in Example 2.

Example 2: Executing different commands with the ExecutePendingCommand method

 private void Button1_Click(object sender, RoutedEventArgs e) 
    { 
        this.VirtualGrid.PendingCommands.Add(RadVirtualGridCommands.MoveDown); 
        this.VirtualGrid.PendingCommands.Add(RadVirtualGridCommands.SelectCurrentUnit); 
        this.VirtualGrid.PendingCommands.Add(RadVirtualGridCommands.Delete); 
        this.VirtualGrid.ExecutePendingCommand(); 
    } 

See Also

In this article