fix: fix page initialization issue.
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
<u:Pagination
|
<u:Pagination
|
||||||
Name="page"
|
Name="page"
|
||||||
PageSizeOptions="10, 20, 50, 100"
|
PageSizeOptions="10, 20, 50, 100"
|
||||||
|
CurrentPage="5"
|
||||||
ShowQuickJump="{Binding #quickJumperSelector.IsChecked}"
|
ShowQuickJump="{Binding #quickJumperSelector.IsChecked}"
|
||||||
ShowPageSizeSelector="{Binding #pageSizeSelector.IsChecked}"
|
ShowPageSizeSelector="{Binding #pageSizeSelector.IsChecked}"
|
||||||
Command="{Binding LoadPageCommand}"
|
Command="{Binding LoadPageCommand}"
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ public class Pagination : TemplatedControl
|
|||||||
private static int? CoerceCurrentPage(AvaloniaObject arg1, int? arg2)
|
private static int? CoerceCurrentPage(AvaloniaObject arg1, int? arg2)
|
||||||
{
|
{
|
||||||
if (arg2 is null) return null;
|
if (arg2 is null) return null;
|
||||||
|
// Only coerce the value if the pagination is initialized. Otherwise the value will be coerced to default because PageCount is not yet determined.
|
||||||
if (arg1 is Pagination { IsInitialized: true } p)
|
if (arg1 is Pagination { IsInitialized: true } p)
|
||||||
{
|
{
|
||||||
arg2 = MathHelpers.SafeClamp(arg2.Value, 1, p.PageCount);
|
arg2 = MathHelpers.SafeClamp(arg2.Value, 1, p.PageCount);
|
||||||
@@ -221,6 +222,7 @@ public class Pagination : TemplatedControl
|
|||||||
LostFocusEvent.AddHandler(OnQuickJumpInputLostFocus, _quickJumpInput);
|
LostFocusEvent.AddHandler(OnQuickJumpInputLostFocus, _quickJumpInput);
|
||||||
|
|
||||||
InitializePanelButtons();
|
InitializePanelButtons();
|
||||||
|
CurrentPage = MathHelpers.SafeClamp(CurrentPage ?? 1, 1, PageCount);
|
||||||
UpdateButtonsByCurrentPage(CurrentPage);
|
UpdateButtonsByCurrentPage(CurrentPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user