Migrate from Xamarin.Forms SfDataGrid to .NET MAUI SfDataGrid

18 Mar 20245 minutes to read

To make migration from Xamarin SfDataGrid to .NET MAUI SfDataGrid easier, we kept most of the APIs from Xamarin SfDataGrid in MAUI SfDataGrid. However, to maintain the consistency of API naming in MAUI SfDataGrid, we renamed some of the APIs. The APIs that have been changed in MAUI SfDataGrid from Xamarin SfDataGrid are detailed as follows.

Namespaces

Xamarin SfDataGrid .NET MAUI SfDataGrid
Syncfusion.SfDataGrid.XForms Syncfusion.Maui.DataGrid
Syncfusion.Data Syncfusion.Maui.Data
Syncfusion.SfDataGrid.XForms.DataPager Syncfusion.Maui.DataGrid.DataPager

Enums

Xamarin SfDataGrid .NET MAUI SfDataGrid Description

ColumnSizer

ColumnWidthMode

Defines constants that specify how the columns in a

SfDataGrid

are sized.

SortTapAction

DataGridSortingGestureType

Defines the constants that specifies how the sorting is applied.

Position

SummaryRowPosition

Defines the constants that specify whether the table summary row is positioned at the top or bottom of the DataGrid.

AutoEllipsisMode

DataPagerEllipsisMode

Defines the constants that describes the possible ellipsis modes for the NumericButton.

ButtonShape

DataPagerButtonShape

Defines the constant that specify the shape of the buttons in the data pager.

NumericButtonsGenerateMode

DataPagerNumericButtonsGenerateMode

Defines the constants that specify whether the numeric buttons should be generated automatically based on parent size or manually using the specified NumericButtonCount value.

PagerDisplayMode

DataPagerDisplayMode

Defines the possible display mode of SfDataPager.

ProgressStates

DataGridProgressState

Defines constants that specify the possible progressing states of resizing operation.

Properties

Xamarin SfDataGrid .NET MAUI SfDataGrid Description

AutoGenerateColumns

AutoGenerateColumnsMode.None

Defines constants that specify how the columns in a

SfDataGrid

are sized.

AllowSorting

SortingMode.Single

Specifies that the single column alone can be sorted at a time.

AllowMultiSorting

SortingMode.Multiple

Specifies that the multiple columns can be sorted.

SortTapAction

SortingGestureType

Defines the constants that specifies how the sorting is applied.

IsHidden

Visible

Gets or sets a value indicating whether a column should be visible.

SelectedItem

SelectedRow

Gets or sets a row which is currently selected.

SelectedItems

SelectedRows

Gets or sets the collection of rows which are all selected.

CurrentItem

CurrentRow

Gets or sets a row which is currently navigated.

HeaderBackgroundColor

HeaderRowBackground

Gets or sets the background for the header row.

RowBackgroundColor

RowBackground

Gets or sets the background of the data rows.

RowForegroundColor

RowTextColor

Gets or sets the text color of the data row.

HeaderForegroundColor

HeaderRowTextColor

Gets or sets the text color of the header row.

GridCellBorderColor

GridLineColor

Gets or sets the color for the grid lines.

GridCellBorderWidth

GridLineStrokeThickness

Gets or sets the stroke thickness of the grid lines.

SelectionBackgroundColor

SelectionBackground

Gets or sets the background of the selected rows.

SelectionForegroundColor

SelectedRowTextColor

Gets or sets the text color of the selected rows.

ColumnSizer

ColumnWidthMode

Gets or sets the value that indicates how all the columns widths are determined.

FontAttribute

DataGridCell.FontAttributes

Gets or sets the font attributes.

HeaderFont

DataGridHeaderCell.FontFamily

Gets or sets the font family.

HeaderFontAttribute

DataGridHeaderCell.FontAttributes

Gets or sets the font attributes.

RecordFont

DataGridCell.FontFamily

Gets or sets the font family.

FrozenRowsCount

FrozenRowCount

The number of non-scrolling rows at the top of SfDataGrid.

FrozenColumnsCount

FrozenColumnCount

The number of non-scrolling columns at the left side of SfDataGrid.

AppearanceManager

DefaultStyle

This enables users to customize the appearance of the data pager.

GetNumericButtonSelectionBackgroundColor

NumericButtonSelectionBackgroundColor

This enables users to customize the selection background color for numeric button.

GetDataPagerBackgroundColor()

DataPagerBackgroundColor

This enables users to customize the background color of the SfDataPager.

GetNavigationButtonIconColor()

NavigationButtonIconColor

This enables users to customize the icon color of the navigation buttons.

GetNumericButtonForegroundColor()

NumericButtonTextColor

This enables users to customize the text color of the numeric values in the navigation buttons.

GetNumericButtonSelectionForegroundColor()

NumericButtonSelectionTextColor

This enables users to customize the text color of the currently selected numeric button in the view.

EnableGridPaging()

- This property isn't available because the [UseOnDemandPaging](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataPager.SfDataPager.html#Syncfusion_Maui_DataGrid_DataPager_SfDataPager_UseOnDemandPaging) property alone is sufficient to enable on-demand paging in the MAUI DataGrid.

AllowResizingColumn

AllowResizingColumns

This enables users to resize the columns by tapping and dragging the right border of the column headers.

Events

Xamarin SfDataGrid .NET MAUI SfDataGrid Description

GridTapped

CellTapped

Occurs when the cell is tapped.

GridDoubleTapped

CellDoubleTapped

Occurs when the cell is tapped twice.

GridLongPressed

CellLongPress

Occurs when the cell is long pressed for particular period.

QueryRowStyle

- This event is not available in MAUI DataGrid. You can write the custom style for

DataGridRow

TargetType.
By writing the converter, you can achieve the requirement conditionally. Refer

Conditional Styling

UG documentation for more information.

QueryCellStyle

- This event is not available in MAUI DataGrid. You can write the custom style for

DataGridCell

TargetType.
By writing the converter, you can achieve the requirement conditionally. Refer

Conditional Styling

UG documentation for more information.

PageIndexChanging

PageChanging

Occurs when page index is being changed.

PageIndexChanged

PageChanged

Occurs when page index is changed.

Methods

Xamarin SfDataGrid .NET MAUI SfDataGrid Description

GetRowHeight

GetIntrinsicRowHeight

Gets the row height to fit that row based on the content.
We have passed the optional parameters such as

canIncludeHiddenColumns

and

excludedColumns

where as we have not provided the

GridRowSizingOptions

class as parameters.

Classes

Xamarin SfDataGrid .NET MAUI SfDataGrid Description

GridColumn

DataGridColumn

Represents the base class for the different column types of the

SfDataGrid

control.

GridNumericColumn

DataGridNumericColumn

A column which is used to handle the numeric values.

GridDateTimeColumn

DataGridDateColumn

A column which is used to show any type of System.DateTime.

GridImageColumn

DataGridImageColumn

A column which is used to show any type of ImageSource.

GridTemplateColumn

DataGridTemplateColumn

A column which is used to show any type of template.

GridTextColumn

DataGridTextColumn

Represents a

SfDataGrid

column that hosts textual Content in its cells.

GridCell

DataGridCell

Represents a record cell in a

SfDataGrid

control.

VirtualizingCellsControl

DataGridRow

Represents a record row in a

SfDataGrid

control.

GridHeaderCellControl

DataGridHeaderCell

Represents a header cell in a

SfDataGrid

control

GridColumnSizer

DataGridColumnSizer

Represents a class that handles the sizing for all the

columns

in the Columns collection in a

SfDataGrid

control.

GridSummaryRow

DataGridSummaryRow

Represents a class that defines the summary information of summary row.

GridTableSummaryRow

DataGridTableSummaryRow

Represents a class that defines summary information of table summary row in

SfDataGrid

.

Position

SummaryRowPosition

Defines the constants that specify whether the table summary row is positioned at the top or bottom of the

SfDataGrid

control.

TableSummaryRowControl

DataGridTableSummaryRowView

Represents a table summary row in a

SfDataGrid

control.

StackedColumn

DataGridStackedColumn

Represents a column that is stacked across the specified child columns in it.

StackedHeaderCellControl

DataGridStackedHeaderCell

Represents a

DataGridStackedCell

in a

SfDataGrid

control.

GridStackedHeaderCellRenderer

DataGridStackedHeaderCellRenderer

A class for cell renderer that displays

DataGridStackedHeaderRow

in a

DataGridStackedCell

.

StackedHeaderRow

DataGridStackedHeaderRow

The

DataGridStackedHeaderRow

contains the collection of

DataGridStackedColumn

to be grouped under a particular category.}}.

GridStackedHeaderCellControl

DataGridStackedHeaderRowView

Represents a

DataGridStackedHeaderRow

as a control in a

SfDataGrid

control.

GridUnboundRows

DataGridUnboundRows

Represents a

DataGridUnboundRows

as a control to add additional rows in a control.

GridUnboundColumn

DataGridUnboundColumn

Represents a

DataGridUnboundColumn

as a control to add additional columns in a control.

AppearanceManager

DataPagerStyle

Represents a class that enables users to customize the appearance of the data pager.

GridResizingEventArgs

DataGridColumnResizingEventArgs

Represents a datagrid column resizing event args.

Known issues

  • [Android] Horizontal scrolling performance is not smooth in the Debug solution configuration when compared to Xamarin.Forms SfDataGrid. However, the scrolling performance is smooth when the solution configuration is Release.

Upcoming Features

  • Right to left (Mac and iOS)
  • Accessibility
  • Custom selection
  • Swiping
  • Column drag and drop
  • Row drag and drop