Skip to content

Pagination

Pagination renders previous/next chevron buttons plus a computed strip of page-number tokens and ellipsis gaps, with the page-list math (PaginationEngine.BuildPageList) kept pure and WPF-independent for direct unit testing. The current page renders as a pressed toggle, reusing NaviusToggleGroupItem from Navius.Wpf.Primitives verbatim for its pressed-state chrome rather than introducing a new button type. Navigation runs through three class RoutedCommands so the template can wire buttons declaratively.

xmlns:pagination="clr-namespace:Navius.Wpf.Ui.Pagination;assembly=Navius.Wpf.Ui"
<pagination:NaviusPagination
TotalPages="12"
CurrentPage="4" />
Property Type Default From Description
TotalPages int 1 NaviusPagination Total number of pages. Clamped to at least 1 internally.
CurrentPage int 1 NaviusPagination Two-way bindable by default. The active page; clamped into [1, TotalPages] by the navigation commands.
SiblingCount int 1 NaviusPagination Pages kept visible on each side of CurrentPage before a gap collapses into an ellipsis.
BoundaryCount int 1 NaviusPagination Pages kept visible at the start and end of the strip regardless of CurrentPage.
Pages IReadOnlyList<PaginationPageToken> - NaviusPagination Read-only. The computed strip of page/ellipsis tokens the template’s ItemsControl binds to; recomputed whenever TotalPages, CurrentPage, SiblingCount, or BoundaryCount changes.
Command Description
NaviusPagination.PreviousCommand Decrements CurrentPage by one. CanExecute is false at CurrentPage == 1.
NaviusPagination.NextCommand Increments CurrentPage by one. CanExecute is false at the last page.
NaviusPagination.GoToPageCommand Sets CurrentPage to the integer command parameter, clamped into [1, TotalPages]. CanExecute requires an int parameter >= 1.

NaviusPagination ships no custom automation peer; it derives from Control and inherits whatever default peer that base provides. The per-page toggle elements are NaviusToggleGroupItem instances from Navius.Wpf.Primitives, so their automation surface is whatever that primitive ships, out of scope for this manifest. The M6 audit’s confirmed fix: PaginationPageToken.Page is a get-only property, so the template’s NaviusToggleGroupItem.IsChecked binding is pinned Mode="OneWay" (both the MultiBinding and each child binding), with an explanatory code comment; binding it TwoWay (the default for IsChecked) would otherwise crash binding activation during the first measure pass since there is no setter to write back to. The unit suite verifies PaginationEngine.BuildPageList’s ellipsis-collapsing math directly (small page counts, a middle current page, a near-start current page, clamping an out-of-range current page, and a zero-page input), plus that the PreviousCommand/NextCommand/GoToPageCommand CanExecute and clamping behavior hold on a live NaviusPagination instance.