Articles in this section
Category / Section

How to adjust row heights of each row based on their content?

1 min read

Xamarin.Forms DataGrid allows you to customize the row height of grid rows using the SfDataGrid.QueryRowHeight event. You can auto fit a row based on its content by using the SfDataGridHelpers.GetRowHeight method.


Handled property of the QueryRowHeightEventArgs must be set to true in the QueryRowHeight event for the height changes to take effect.


<sfGrid:SfDataGrid x:Name="dataGrid"
    <sfGrid:GridTextColumn MappingName="OrderId" />
    <sfGrid:GridTextColumn MappingName="CustomerId" />
    <sfGrid:GridTemplateColumn MappingName="CustomerQuery">
          <Label Text="{Binding CustomerQuery}" />
    <sfGrid:GridTextColumn MappingName="Country" />


private ViewModel viewModel;
public MainPage()
       viewModel = new ViewModel();
       dataGrid.ItemsSource = viewModel.OrdersInfo;
       dataGrid.QueryRowHeight += DataGrid_QueryRowHeight;
private void DataGrid_QueryRowHeight(object sender, Syncfusion.SfDataGrid.XForms.QueryRowHeightEventArgs e)
        if(e.RowIndex > 0)
             e.Height = SfDataGridHelpers.GetRowHeight(dataGrid, e.RowIndex);
             e.Handled = true;



To skip the header row the condition (e.RowIndex > 0) is added.





Sample Link

How to adjust row heights of each row based on their content?



I hope you enjoyed learning about how to adjust row heights of each row based on their content.

You can refer to our  Xamarin.Forms DataGrid feature tour page to know about its other groundbreaking feature representations. You can also explore our  Xamarin.Forms DataGrid documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Please sign in to leave a comment