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

Pinned Rows and Columns

VirtualGrid provides a pinning mechanism for both its rows and columns. Through it, a given row can be pinned to the top or bottom of the grid. Respectively, a column can be pinned to the left or right side of VirtualGrid. Thus, they will not take part in the vertical or horizontal scrolling.

Pin Rows and Columns

The pin functionality can be controlled using the following methods exposed by the API of the control.

  • PinRowTop(int index)—Pins a row at a given index on the top.

    Example 1: Calling the PinRowTop method

        virtualGrid.PinRowTop(1); 
    

    Figure 1: RadVirtualGrid with pinned row at the top

    RadVirtualGrid with pinned row on the top

  • PinRowBotton(int index)—Pins a row at a given index to the bottom.

    Example 2: Calling the PinRowBottom method

        virtualGrid.PinRowBottom(1); 
    

    Figure 2: RadVirtualGrid with pinned row at the bottom

    RadVirtualGrid with pinned row at the bottom

  • PinColumnLeft(int index)—Pins a column at a given index to the left.

    Example 3: Calling the PinColumnLeft method

        virtualGrid.PinColumnLeft(1); 
    

    Figure 3: RadVirtualGrid with pinned column on the left

     RadVirtualGrid with pinned column on the left

  • PinColumnRight(int index)—Pins a column at a given index to the right.

    Example 4: Calling the PinColumnRight method

        virtualGrid.PinColumnRight(1); 
    

    Figure 4: RadVirtualGrid with pinned column on the right

    RadVirtualGrid with pinned column on the right

Unpin Rows and Columns

Unpinning an already pinned row or column can be achieved through the UnpinRow and UnpinColumn methods.

  • UnpinRow(int index)—Unpins a row at a given index.

  • UnpinColumn(int index)—Unpins a column at a given index.

Example 5: Unpin methods usage

virtualGrid.UnpinRow(1); 
virtualGrid.UnpinColumn(1); 

Commands Support

VirtualGrid exposes built-in commands for its pinning functionality. They can be accessed via the RadVirtualGridCommands and executed using the PendingCommands collection property of the VirtualGrid and its ExecutePendingCommand method.

The available commands are PinRowTop, PinRowBottom, PinColumnLeft, PinColumnRight, UnpinRow and UnpinColumn. Read more about the commanding support in the Commands Overview article.

Usage with Filtering and Sorting

The pinned rows feature is not supported when filtering or sorting is applied. In case you already have pinned rows and then apply filtering or sorting, the rows will get unpinned. After, the filtering and sorting is cleared, the previously pinned rows will be restored.

See also

In this article