Hello,
I like to set the page size based on the DataGrid size, such that no scroll bar appears.
So I set the PageSize to the following values in the Window_Loaded event-handler:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
for (var tabIndex = MainTabControl.Items.Count - 1; tabIndex >= 0; tabIndex--)
{
MainTabControl.SelectedIndex = tabIndex;
MainTabControl.UpdateLayout();
}
dpOrderHistory.PageSize = (int)(dgOrderHistory.ActualHeight / dgOrderHistory.RowHeight); dpOrderList.PageSize = (int)(dpOrderList.ActualHeight / dgOrderList.RowHeight); }
Here is my XAML-Code:
<TabControl x:Name="MainTabControl">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding CMDSelectedTabChanged}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<TabItem Header="Bestellliste" >
<DockPanel>
<syncfusion:SfDataPager x:Name="dpOrderList" Source="{Binding TotalProductList}"
PageSize="20" DockPanel.Dock="Bottom"/>
<syncfusion:SfDataGrid x:Name="dgOrderList" ItemsSource="{Binding PagedSource, ElementName=dpOrderList}" SelectionMode="Single" CellTapped="dgOrderList_CellTapped" AutoGeneratingColumn="dgOrderList_AutoGeneratingColumn" AllowSorting="False">
</syncfusion:SfDataGrid>
</DockPanel>
</TabItem>
<TabItem Header="Bestellhistorie">
<DockPanel>
<syncfusion:SfDataPager x:Name="dpOrderHistory" Source="{Binding TotalOrderStatusList}"
PageSize="20" DockPanel.Dock="Bottom"/>
<syncfusion:SfDataGrid x:Name="dgOrderHistory" ItemsSource="{Binding PagedSource, ElementName=dpOrderHistory}" SelectionMode="Single" CellTapped="dgOrderHistory_CellTapped" AutoGeneratingColumn="dgOrderHistory_AutoGeneratingColumn" AllowSorting="False" >
</syncfusion:SfDataGrid>
</DockPanel>
</TabItem>
</TabControl>
If I run the program, the PageSize is still 20. If i do not specify the value in XAML then no rows are displayed in the DataGrid. However I bound a Label to the PageSize value and it displays 34, but the grid shows only 20 items.
How should I change the code such that the grid displays as much items as possible without scrollbars.
Which Event is the right place to compute the PageSize?