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?