Articles in this section
Category / Section

How to load SfDataGrid with specific height and width?

1 min read

You can load SfDataGrid with specific height and width inside different layouts using SfDataGrid.HeightRequest and SfDataGrid.WidthRequest property. You need to set the HorizontalOptions and VerticalOptions for the grid accordingly.

For example, if you are setting width request then you should set the HorizontalOptions of the SfDataGrid based on your requirement and if you are setting the height request then you should set the VerticalOptions of the grid accordingly. In case of setting both, you need to set both HorizontalOptions and VerticalOptions accordingly.

SfDataGrid dataGrid;
 
public App()
{
    dataGrid = new SfDataGrid
    {
        ItemsSource = new ViewModel().OrdersInfo,
        ColumnSizer = ColumnSizer.Star,
        VerticalOptions = LayoutOptions.Center,
        HeightRequest = 200
    };
 
    MainPage = new ContentPage
    {
        Content = dataGrid
    };
}

 

Screenshot:

 

Sample Link:

How to load SfDataGrid with specific height and width inside different layouts?

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied