Loading...
Loading...
Implements Syncfusion WPF DataPager (SfDataPager) for paginating large datasets in WPF applications. Use this when implementing pagination controls, page navigation, or splitting large data into manageable chunks. Supports configurable page sizes, navigation buttons, numeric page buttons, and works with DataGrid, ListBox, ListView, and ItemsControl.
npx skill4agent add syncfusion/wpf-ui-components-skills syncfusion-wpf-datapager<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sfgrid="clr-namespace:Syncfusion.UI.Xaml.Grid;assembly=Syncfusion.SfGrid.WPF"
xmlns:datapager="clr-namespace:Syncfusion.UI.Xaml.Controls.DataPager;assembly=Syncfusion.SfGrid.WPF">
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- DataGrid displays paginated data -->
<sfgrid:SfDataGrid AutoGenerateColumns="True"
ItemsSource="{Binding ElementName=sfDataPager, Path=PagedSource}"/>
<!-- DataPager provides navigation -->
<datapager:SfDataPager x:Name="sfDataPager"
Grid.Row="1"
NumericButtonCount="10"
PageSize="10"
Source="{Binding OrdersDetails}"/>
</Grid>
</Window>OrdersDetails<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<sfgrid:SfDataGrid ItemsSource="{Binding ElementName=sfDataPager, Path=PagedSource}"/>
<datapager:SfDataPager x:Name="sfDataPager"
Grid.Row="1"
PageSize="20"
Source="{Binding DataCollection}"/>
</Grid><datapager:SfDataPager x:Name="sfDataPager"
AccentBackground="DodgerBlue"
AccentForeground="White"
AutoEllipsisMode="Both"
NumericButtonCount="5"
PageSize="15"
Source="{Binding DataCollection}"/><Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<sfgrid:SfDataGrid ItemsSource="{Binding ElementName=sfDataPager, Path=PagedSource}"/>
<ComboBox Name="pageSizeComboBox"
Grid.Column="1" Grid.Row="1"
SelectedIndex="0"
ItemsSource="{Binding PageSizeOptions}"/>
<datapager:SfDataPager x:Name="sfDataPager"
Grid.Row="1"
PageSize="{Binding SelectedValue, ElementName=pageSizeComboBox}"
Source="{Binding DataCollection}"/>
</Grid><datapager:SfDataPager x:Name="sfDataPager"
UseOnDemandPaging="True"
PageCount="100"
PageSize="20"
OnDemandLoading="OnDemandDataLoading"/>private void OnDemandDataLoading(object sender, OnDemandLoadingEventArgs args)
{
// Load data for current page only
var pageData = dataSource.Skip(args.StartIndex).Take(args.PageSize);
sfDataPager.LoadDynamicItems(args.StartIndex, pageData);
}<datapager:SfDataPager PageIndexChanging="sfDataPager_PageIndexChanging"/>private void sfDataPager_PageIndexChanging(object sender, PageIndexChangingEventArgs e)
{
// Validate or prompt user before page change
if (HasUnsavedChanges())
{
var result = MessageBox.Show("Unsaved changes. Continue?",
"Confirm",
MessageBoxButton.YesNo);
if (result == MessageBoxResult.No)
{
e.Cancel = true; // Cancel page navigation
}
}
}| Property | Type | Description |
|---|---|---|
| IEnumerable | Data collection for paging |
| PagedCollectionView | Paginated data (bind to ItemsSource) |
| int | Items per page (default: 0 = all items) |
| int | Current page index (0-based) |
| int | Total number of pages |
| int | Number of numeric buttons to display |
| AutoEllipsisMode | Ellipsis button placement (After, Before, Both, None) |
| Brush | Background color for navigation/selected buttons |
| Brush | Foreground color for selected button |
| PageDisplayMode | Which buttons to show (e.g., FirstLastPreviousNextNumeric) |
| Orientation | Horizontal or Vertical layout |
| bool | Enable on-demand data loading |
| Method | Description |
|---|---|
| Navigate to first page |
| Navigate to last page |
| Navigate to next page |
| Navigate to previous page |
| Navigate to specific page |
| Load data for on-demand paging |
| Event | Description |
|---|---|
| Before page changes (cancelable) |
| After page changes |