diff --git a/demo/Ursa.Demo/Pages/PaginationDemo.axaml b/demo/Ursa.Demo/Pages/PaginationDemo.axaml
index a90dfbe..22d4ebc 100644
--- a/demo/Ursa.Demo/Pages/PaginationDemo.axaml
+++ b/demo/Ursa.Demo/Pages/PaginationDemo.axaml
@@ -28,5 +28,10 @@
Command="{Binding LoadPageCommand}"
CommandParameter="{Binding $self.CurrentPage}"
TotalCount="600" />
+
+
+
+
diff --git a/src/Ursa.Themes.Semi/Controls/Pagination.axaml b/src/Ursa.Themes.Semi/Controls/Pagination.axaml
index 41cdecb..6b2eeca 100644
--- a/src/Ursa.Themes.Semi/Controls/Pagination.axaml
+++ b/src/Ursa.Themes.Semi/Controls/Pagination.axaml
@@ -12,7 +12,7 @@
-
+
-
+
-
+
-
+
@@ -48,6 +51,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -130,4 +190,4 @@
-
+
\ No newline at end of file
diff --git a/src/Ursa/Controls/Pagination/Pagination.cs b/src/Ursa/Controls/Pagination/Pagination.cs
index cac9b54..8f5b703 100644
--- a/src/Ursa/Controls/Pagination/Pagination.cs
+++ b/src/Ursa/Controls/Pagination/Pagination.cs
@@ -1,3 +1,4 @@
+using System.Windows.Input;
using Avalonia;
using Avalonia.Collections;
using Avalonia.Controls;
@@ -7,154 +8,75 @@ using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Styling;
using Irihi.Avalonia.Shared.Helpers;
-using System.Windows.Input;
namespace Ursa.Controls;
///
-/// Pagination is a control that displays a series of buttons that can be used to navigate to pages.
-/// CurrentPage starts from 1.
-/// Pagination only stores an approximate index internally.
+/// Pagination is a control that displays a series of buttons that can be used to navigate to pages.
+/// CurrentPage starts from 1.
+/// Pagination only stores an approximate index internally.
///
[TemplatePart(PART_PreviousButton, typeof(PaginationButton))]
[TemplatePart(PART_NextButton, typeof(PaginationButton))]
[TemplatePart(PART_ButtonPanel, typeof(StackPanel))]
[TemplatePart(PART_QuickJumpInput, typeof(NumericIntUpDown))]
-public class Pagination: TemplatedControl
+public class Pagination : TemplatedControl
{
public const string PART_PreviousButton = "PART_PreviousButton";
public const string PART_NextButton = "PART_NextButton";
public const string PART_ButtonPanel = "PART_ButtonPanel";
public const string PART_QuickJumpInput = "PART_QuickJumpInput";
- private PaginationButton? _previousButton;
- private PaginationButton? _nextButton;
- private StackPanel? _buttonPanel;
- private readonly PaginationButton[] _buttons = new PaginationButton[7];
- private NumericIntUpDown? _quickJumpInput;
public static readonly StyledProperty CurrentPageProperty = AvaloniaProperty.Register(
- nameof(CurrentPage));
-
- public int? CurrentPage
- {
- get => GetValue(CurrentPageProperty);
- set => SetValue(CurrentPageProperty, value);
- }
-
- private void OnCurrentPageChanged(AvaloniaPropertyChangedEventArgs args)
- {
- int? oldValue = args.GetOldValue();
- int? newValue = args.GetNewValue();
- var e = new ValueChangedEventArgs(CurrentPageChangedEvent, oldValue, newValue);
- RaiseEvent(e);
- }
+ nameof(CurrentPage), coerce: CoerceCurrentPage);
public static readonly RoutedEvent> CurrentPageChangedEvent =
- RoutedEvent.Register>(nameof(CurrentPageChanged), RoutingStrategies.Bubble);
-
- ///
- /// Raised when the changes.
- ///
- public event EventHandler>? CurrentPageChanged
- {
- add => AddHandler(CurrentPageChangedEvent, value);
- remove => RemoveHandler(CurrentPageChangedEvent, value);
- }
+ RoutedEvent.Register>(nameof(CurrentPageChanged),
+ RoutingStrategies.Bubble);
public static readonly StyledProperty CommandProperty = AvaloniaProperty.Register(
nameof(Command));
- public ICommand? Command
- {
- get => GetValue(CommandProperty);
- set => SetValue(CommandProperty, value);
- }
-
- public static readonly StyledProperty