blanck space in data grid

In the page I am using DataGrid I have 2 rows and 2 columns with the same height and width 

between the actual dataGrid and the Vertical Scroll ball I have a blank space 

here the code of datagrid 

<syncfusion:SfDataGrid ColumnWidthMode="Auto" GridLinesVisibility="Both" Grid.RowSpan="2" Grid.Row="0" Grid.Column="0" ItemsSource="{Binding ******}"

</syncfusion:SfDataGrid>

I ve tried to give it a specific widht but nothing changed

What could be the problem and thank you



1 Reply

KK Karthikraja Kalaimani Syncfusion Team April 24, 2023 11:11 AM UTC

Hi Hami,

You can achieve your requirement by setting the MinimumHeightRequest and MinimumWidthRequest to 0 and set the HeightRequest and WidthRequest based on the Total row and columns count in DataGrid on datagrid loaded event. For more details, please refer to the following code snippets.

Code snippet :


.....
private void dataGrid_Loaded(object sender, EventArgs e)
{
this.dataGrid.MinimumHeightRequest = 0;
this.dataGrid.MinimumWidthRequest = 0;
CalculateHeight();
}

private void CalculateHeight()
{
var height = (ViewModel.OrderInfoCollection.Count * dataGrid.RowHeight) + dataGrid.HeaderRowHeight;
var width = 

(double)(this.dataGrid.Children[0] as ScrollView).Content.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name == "ExtentWidth").GetValue((this.dataGrid.Children[0] as ScrollView).Content) as double? ?? 0;

if (height <= 300)
{
this.dataGrid.WidthRequest = width;
this.dataGrid.HeightRequest = (double)height;
}
else
{
this.dataGrid.WidthRequest = 300;
this.dataGrid.HeightRequest = 300;
}
}
...

Regards,
Karthik Raja

Loader.
Up arrow icon