Freeze Panes in Xamarin DataGrid (SfDataGrid)

The SfDataGrid allows to freeze the rows and columns when scrolling the grid.

Freeze rows

The SfDataGrid provides extensive support to freeze the rows at the top of the view below the header row by setting the SfDataGrid.FrozenRowsCount property.

The following code example illustrates freezing two rows:

  • c#
  • //Setting number of rows to freeze in SfDataGrid
    dataGrid.FrozenRowsCount = 2;

    Limitation

    • FrozenRowsCount should be lesser than the number of rows displayed in view. For example, If you have 10 rows in view, then you set FrozenRowsCount to a maximum value of 9.

    NOTE

    Header row is frozen by default and works regardless of the FrozenRowsCount property.

    Freeze columns

    The SfDataGrid also supports to freeze the columns at the left of the view by setting the SfDataGrid.FrozenColumnsCount property.

    The following code example illustrates freezing two columns:

  • c#
  • //Setting number of columns to freeze in SfDataGrid
    dataGrid.FrozenColumnsCount = 2; 

    Limitation

    • FrozenColumnsCount should be lesser than number of columns displayed in view. For example, If you have 5 columns in view, then you can set FrozenColumnsCount to a maximum value of 4.

    NOTE

    RowHeader is frozen by default and works regardless of the FrozenColumnsCount property.

    The following GIF illustrates FrozenRows and FrozenColumns.

    DataGrid with row pinning and column pinning