Class SfDataPager
Represents a control that enables navigation through paged data.
Implements
Inherited Members
Namespace: Syncfusion.Maui.DataPager
Assembly: Syncfusion.Maui.DataPager.dll
Syntax
public class SfDataPager : SfView, IDrawableLayout, IDrawable, IAbsoluteLayout, ILayout, IView, IElement, ITransform, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISafeAreaView, IPadding, ICrossPlatformLayout, IVisualTreeElement
Remarks
The SfDataPager divides a data source into multiple pages and provides navigation options to move between them. It also supports on-demand data loading for improved performance with large data collections.
Constructors
SfDataPager()
Initializes a new instance of the SfDataPager class.
Declaration
public SfDataPager()
Fields
AutoEllipsisModeProperty
Identifies the AutoEllipsisMode Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty AutoEllipsisModeProperty
Field Value
| Type |
|---|
| BindableProperty |
AutoEllipsisTextProperty
Identifies the AutoEllipsisText Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty AutoEllipsisTextProperty
Field Value
| Type |
|---|
| BindableProperty |
ButtonCornerRadiusProperty
Identifies the ButtonCornerRadius Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty ButtonCornerRadiusProperty
Field Value
| Type |
|---|
| BindableProperty |
ButtonFontSizeProperty
Identifies the ButtonFontSize Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty ButtonFontSizeProperty
Field Value
| Type |
|---|
| BindableProperty |
ButtonShapeProperty
Identifies the ButtonShape Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty ButtonShapeProperty
Field Value
| Type |
|---|
| BindableProperty |
ButtonSizeProperty
Identifies the ButtonSize Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty ButtonSizeProperty
Field Value
| Type |
|---|
| BindableProperty |
ButtonSpacingProperty
Identifies the ButtonSpacing Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty ButtonSpacingProperty
Field Value
| Type |
|---|
| BindableProperty |
DataPagerStyleProperty
Identifies the DataGridStyle Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty DataPagerStyleProperty
Field Value
| Type |
|---|
| BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
DisplayModeProperty
Identifies the DisplayMode Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty DisplayModeProperty
Field Value
| Type |
|---|
| BindableProperty |
EnableLiquidGlassEffectProperty
Bindable property for EnableLiquidGlassEffect
Declaration
public static readonly BindableProperty EnableLiquidGlassEffectProperty
Field Value
| Type |
|---|
| BindableProperty |
FirstPageButtonTemplateProperty
Identifies the FirstPageTemplate Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty FirstPageButtonTemplateProperty
Field Value
| Type |
|---|
| BindableProperty |
LastPageButtonTemplateProperty
Identifies the LastPageTemplate Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty LastPageButtonTemplateProperty
Field Value
| Type |
|---|
| BindableProperty |
NavigateToFirstPageCommandProperty
Identifies the NavigateToFirstPageCommand Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NavigateToFirstPageCommandProperty
Field Value
| Type |
|---|
| BindableProperty |
NavigateToLastPageCommandProperty
Identifies the NavigateToLastPageCommand Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NavigateToLastPageCommandProperty
Field Value
| Type |
|---|
| BindableProperty |
NavigateToNextPageCommandProperty
Identifies the NavigateToNextPageCommand Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NavigateToNextPageCommandProperty
Field Value
| Type |
|---|
| BindableProperty |
NavigateToPageCommandParameterProperty
Identifies the NavigateToPageCommandParameter Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NavigateToPageCommandParameterProperty
Field Value
| Type |
|---|
| BindableProperty |
NavigateToPageCommandProperty
Identifies the NavigateToPageCommand Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NavigateToPageCommandProperty
Field Value
| Type |
|---|
| BindableProperty |
NavigateToPreviousPageCommandProperty
Identifies the NavigateToPreviousPageCommand Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NavigateToPreviousPageCommandProperty
Field Value
| Type |
|---|
| BindableProperty |
NextPageButtonTemplateProperty
Identifies the NextPageTemplate Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NextPageButtonTemplateProperty
Field Value
| Type |
|---|
| BindableProperty |
NumericButtonCountProperty
Identifies the NumericButtonCount Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NumericButtonCountProperty
Field Value
| Type |
|---|
| BindableProperty |
NumericButtonTemplateProperty
Identifies the NumericButtonTemplate Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NumericButtonTemplateProperty
Field Value
| Type |
|---|
| BindableProperty |
NumericButtonsGenerateModeProperty
Identifies the NumericButtonsGenerateMode Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NumericButtonsGenerateModeProperty
Field Value
| Type |
|---|
| BindableProperty |
OrientationProperty
Identifies the Orientation Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty OrientationProperty
Field Value
| Type |
|---|
| BindableProperty |
PageCountProperty
Identifies the PageCount Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty PageCountProperty
Field Value
| Type |
|---|
| BindableProperty |
PageIndexProperty
Identifies the PageIndex Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty PageIndexProperty
Field Value
| Type |
|---|
| BindableProperty |
PageSizeProperty
Identifies the PageSize Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty PageSizeProperty
Field Value
| Type |
|---|
| BindableProperty |
PagedSourceProperty
Identifies the PagedSource Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty PagedSourceProperty
Field Value
| Type |
|---|
| BindableProperty |
PreviousPageButtonTemplateProperty
Identifies the PreviousPageTemplate Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty PreviousPageButtonTemplateProperty
Field Value
| Type |
|---|
| BindableProperty |
SourceProperty
Identifies the Source Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty SourceProperty
Field Value
| Type |
|---|
| BindableProperty |
TargetGridProperty
Bindable property for TargetGrid
Declaration
public static readonly BindableProperty TargetGridProperty
Field Value
| Type |
|---|
| BindableProperty |
UseOnDemandPagingProperty
Identifies the UseOnDemandPaging Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty UseOnDemandPagingProperty
Field Value
| Type |
|---|
| BindableProperty |
Properties
AutoEllipsisMode
Gets or sets AutoEllipsisMode, which indicates the possible ellipsis mode for the numeric button in the SfDataPager. By default, all the numeric buttons in the page will be in view.
Declaration
public DataPagerEllipsisMode AutoEllipsisMode { get; set; }
Property Value
| Type |
|---|
| DataPagerEllipsisMode |
AutoEllipsisText
Gets or sets the text for the numeric button in auto ellipsis mode. By default, all the numeric buttons in the page will be in view.
Declaration
public string AutoEllipsisText { get; set; }
Property Value
| Type |
|---|
| string |
ButtonCornerRadius
Gets or Sets the corner radius for the page buttons when DataPager.ButtonShape is DataPager.ButtonShape.Rectangle. The default value is 2.
Declaration
public double ButtonCornerRadius { get; set; }
Property Value
| Type |
|---|
| double |
ButtonFontSize
Gets or sets the font size of all the buttons in the SfDataPager control. The default value is 14.
Declaration
public double ButtonFontSize { get; set; }
Property Value
| Type |
|---|
| double |
ButtonShape
Gets or sets the shape of the buttons in the data pager. Default value is DataPager.ButtonShape.Circle.
Declaration
public DataPagerButtonShape ButtonShape { get; set; }
Property Value
| Type |
|---|
| DataPagerButtonShape |
ButtonSize
Gets or sets a value that acts as the width and height of all the buttons in the SfDataPager. The default value is 40.
Declaration
public double ButtonSize { get; set; }
Property Value
| Type |
|---|
| double |
ButtonSpacing
Gets or sets the spacing between the buttons when button shape is Rectangle. The default value is 8.
Declaration
public double ButtonSpacing { get; set; }
Property Value
| Type |
|---|
| double |
DefaultStyle
Gets or sets the datapager style, SfDataPager enables the user to customize the appearance of the pager by writing a Style
Declaration
public DataPagerStyle DefaultStyle { get; set; }
Property Value
| Type |
|---|
| DataPagerStyle |
DisplayMode
Gets or sets the page display mode for the SfDataPager. The user can customize the buttons to be displayed in the pager. The default value is FirstLastPreviosNextNumeric.
Declaration
public DataPagerDisplayMode DisplayMode { get; set; }
Property Value
| Type |
|---|
| DataPagerDisplayMode |
EnableLiquidGlassEffect
Gets or sets a value indicating whether to enable the liquid glass effect.
Declaration
public bool EnableLiquidGlassEffect { get; set; }
Property Value
| Type |
|---|
| bool |
FirstPageButtonTemplate
Gets or sets the first page template for first page button.
Declaration
public DataTemplate FirstPageButtonTemplate { get; set; }
Property Value
| Type |
|---|
| DataTemplate |
LastPageButtonTemplate
Gets or sets the lat page template for last page button.
Declaration
public DataTemplate LastPageButtonTemplate { get; set; }
Property Value
| Type |
|---|
| DataTemplate |
NavigateToFirstPageCommand
Gets or sets the command that is executed when navigation to the first page succeeds.
Declaration
public ICommand? NavigateToFirstPageCommand { get; set; }
Property Value
| Type |
|---|
| ICommand |
Remarks
Assign an ICommand to observe first-page navigation without code-behind. This command is executed after the existing navigation workflow completes successfully.
NavigateToLastPageCommand
Gets or sets the command that is executed when navigation to the last page succeeds.
Declaration
public ICommand? NavigateToLastPageCommand { get; set; }
Property Value
| Type |
|---|
| ICommand |
Remarks
Assign an ICommand to observe last-page navigation without code-behind. This command is executed after the existing navigation workflow completes successfully.
NavigateToNextPageCommand
Gets or sets the command that is executed when navigation to the next page succeeds.
Declaration
public ICommand? NavigateToNextPageCommand { get; set; }
Property Value
| Type |
|---|
| ICommand |
Remarks
Assign an ICommand to observe next-page navigation without code-behind. This command is executed after the existing navigation workflow completes successfully.
NavigateToPageCommand
Gets or sets the command that is executed when navigation to a specific page succeeds.
Declaration
public ICommand? NavigateToPageCommand { get; set; }
Property Value
| Type |
|---|
| ICommand |
Remarks
Assign an ICommand to observe page navigation without code-behind. The command is executed after the existing navigation workflow completes successfully. When NavigateToPageCommandParameter is set, its value is used as the command parameter; otherwise the destination page index is passed as the command parameter.
NavigateToPageCommandParameter
Gets or sets the parameter passed to the NavigateToPageCommand when specific page navigation completes.
Declaration
public object? NavigateToPageCommandParameter { get; set; }
Property Value
| Type |
|---|
| object |
Remarks
When this property is set, its value is used as the command parameter instead of the destination page index.
NavigateToPreviousPageCommand
Gets or sets the command that is executed when navigation to the previous page succeeds.
Declaration
public ICommand? NavigateToPreviousPageCommand { get; set; }
Property Value
| Type |
|---|
| ICommand |
Remarks
Assign an ICommand to observe previous-page navigation without code-behind. This command is executed after the existing navigation workflow completes successfully.
NextPageButtonTemplate
Gets or sets the next page template for next page button.
Declaration
public DataTemplate NextPageButtonTemplate { get; set; }
Property Value
| Type |
|---|
| DataTemplate |
NumericButtonCount
Gets or sets the number of buttons to be displayed in the view in SfDataPager.
Declaration
public int NumericButtonCount { get; set; }
Property Value
| Type |
|---|
| int |
NumericButtonTemplate
Gets or sets the Microsoft.Maui.Controls.DataTemplate used to customize the content of the numeric buttons in the SfDataPager. The binding context of the template content is a BindingContextHelper instance exposing the page number via the PageNumber property. The default value is null, which renders the built-in numeric button content.
Declaration
public DataTemplate? NumericButtonTemplate { get; set; }
Property Value
| Type |
|---|
| DataTemplate |
NumericButtonsGenerateMode
Gets or sets a value indicating how the numeric buttons should be generated in the view.
Declaration
public DataPagerNumericButtonsGenerateMode NumericButtonsGenerateMode { get; set; }
Property Value
| Type |
|---|
| DataPagerNumericButtonsGenerateMode |
Orientation
Gets or sets the scroll orientation of the data pager. Users can customize the pager to be scrolled vertically or horizontally. The default orientation is horizontal.
Declaration
public DataPagerScrollOrientation Orientation { get; set; }
Property Value
| Type |
|---|
| DataPagerScrollOrientation |
PageCount
Gets or sets the page count, which returns the total number of pages in SfDataPager.
Declaration
public int PageCount { get; set; }
Property Value
| Type |
|---|
| int |
PageIndex
Gets or sets the page index, which indicates the current page index.
Declaration
public int PageIndex { get; set; }
Property Value
| Type |
|---|
| int |
PageSize
Gets or sets the page size, used to set total number of rows to be displayed in the grid.
Declaration
public int PageSize { get; set; }
Property Value
| Type |
|---|
| int |
PagedSource
Gets or sets the PagedSource of the SfDataPager, which is assigned to the item source of the SfDataGrid.
Declaration
public object PagedSource { get; set; }
Property Value
| Type |
|---|
| object |
PreviousPageButtonTemplate
Gets or sets the previous page template for previous page button.
Declaration
public DataTemplate PreviousPageButtonTemplate { get; set; }
Property Value
| Type |
|---|
| DataTemplate |
Source
Gets or sets the items source of the SfDataPager. SfDataPager is bind to the observable collection of data. This property is set only when normal paging is used, since setting this property loads all the items to the grid initially.
Declaration
public IEnumerable Source { get; set; }
Property Value
| Type |
|---|
| IEnumerable |
TargetGrid
Gets or sets the SfDataGrid associated with this pager.
Declaration
public object TargetGrid { get; set; }
Property Value
| Type |
|---|
| object |
UseOnDemandPaging
Gets or sets a value indicating whether to enable/disable OnDemandPaging. SfDataPager enables the user to generate the items for the current page dynamically by using this property.
Declaration
public bool UseOnDemandPaging { get; set; }
Property Value
| Type |
|---|
| bool |
Methods
ArrangeContent(Rect)
Arranges the view.
Declaration
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "The SetVisualState method is not trim compatible")]
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "The SetVisualState method relies on dynamic code generation")]
protected override Size ArrangeContent(Rect bounds)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | bounds | The bounds of the view. |
Returns
| Type | Description |
|---|---|
| Size | Returns the size of the view. |
Overrides
LoadDynamicItems(int, IEnumerable)
This method dynamically loads items into the PagedSource on demand. This method is used when UseOnDemandPaging is enabled to load the items dynamically to the page only when navigating to the page.
Declaration
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "The LoadDynamicItems method is not trim compatible")]
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "The LoadDynamicItems method relies on dynamic code generation")]
public void LoadDynamicItems(int startIndex, IEnumerable items)
Parameters
| Type | Name | Description |
|---|---|---|
| int | startIndex | The start index of the items to be loaded. |
| IEnumerable | items | The items to be loaded in the page. |
MeasureContent(double, double)
Measures the DataPager.
Declaration
protected override Size MeasureContent(double widthConstraint, double heightConstraint)
Parameters
| Type | Name | Description |
|---|---|---|
| double | widthConstraint | The Width. |
| double | heightConstraint | The Height. |
Returns
| Type | Description |
|---|---|
| Size | It returns the size. |
Overrides
MoveToFirstPage()
Moves to the first page. This method is used to navigate to the first page programmatically.
Declaration
public void MoveToFirstPage()
MoveToLastPage()
Moves to the last page. This method is used to navigate to the last page programmatically.
Declaration
public void MoveToLastPage()
MoveToNextPage()
Moves to the next page. This method is used to navigate to the next page programmatically.
Declaration
public void MoveToNextPage()
MoveToPage(int)
Moves to the given page index. This method is used to navigate to the desired page programmatically.
Declaration
public void MoveToPage(int pageIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | pageIndex | The page index to move to. |
MoveToPage(int, int, bool)
Moves to the given page index. This method is used to navigate to the desired page programmatically from the current page.
Declaration
public void MoveToPage(int oldPageIndex, int pageIndex, bool animateScrolling = false)
Parameters
| Type | Name | Description |
|---|---|---|
| int | oldPageIndex | The old page index which represents the current page index. |
| int | pageIndex | The page index to move to. |
| bool | animateScrolling | The value indicating whether scrolling can animated. |
MoveToPreviousPage()
Moves to the previous page. This method is used to navigate to the previous page programmatically.
Declaration
public void MoveToPreviousPage()
OnPropertyChanged(string)
Called when the property of DataPager is changed.
Declaration
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "The SetVisualState method is not trim compatible")]
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "The SetVisualState method relies on dynamic code generation")]
protected override void OnPropertyChanged(string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyName |
Refresh()
Refresh the SfDataPager in runtime.
Declaration
public void Refresh()
Events
OnDemandLoading
Occurs when data is requested for a page in on-demand loading mode.
Declaration
public event EventHandler<OnDemandLoadingEventArgs>? OnDemandLoading
Event Type
| Type |
|---|
| EventHandler<OnDemandLoadingEventArgs> |
Remarks
This event is raised when the SfDataPager requires data for the currently requested page. Handle this event to load page data dynamically instead of loading the entire data source at once.
PageChanged
Occurs after the current page has been changed successfully.
Declaration
public event EventHandler<PageChangedEventArgs>? PageChanged
Event Type
| Type |
|---|
| EventHandler<PageChangedEventArgs> |
Remarks
This event is raised when navigation to a new page is completed. Use this event to perform actions that depend on the updated page index.
PageChanging
Occurs before the current page is changed.
Declaration
public event EventHandler<PageChangingEventArgs>? PageChanging
Event Type
| Type |
|---|
| EventHandler<PageChangingEventArgs> |
Remarks
This event is raised when a page navigation request is initiated, but before the page transition occurs. Use this event to validate or cancel page navigation if required.