diff --git a/demo/Ursa.Demo/Pages/PaginationDemo.axaml b/demo/Ursa.Demo/Pages/PaginationDemo.axaml
index bd14888..9af5f60 100644
--- a/demo/Ursa.Demo/Pages/PaginationDemo.axaml
+++ b/demo/Ursa.Demo/Pages/PaginationDemo.axaml
@@ -13,6 +13,10 @@
-
+
+
diff --git a/src/Ursa.Themes.Semi/Controls/Pagination.axaml b/src/Ursa.Themes.Semi/Controls/Pagination.axaml
index de80998..03cd756 100644
--- a/src/Ursa.Themes.Semi/Controls/Pagination.axaml
+++ b/src/Ursa.Themes.Semi/Controls/Pagination.axaml
@@ -24,12 +24,33 @@
-
+
-
+ IsOpen="{TemplateBinding IsDropdownOpen,
+ Mode=TwoWay}"
+ PlacementTarget="PART_Button">
+
+
+
+
+
+
+
+
+
diff --git a/src/Ursa/Controls/Pagination/Pagination.cs b/src/Ursa/Controls/Pagination/Pagination.cs
index 9b04540..002985a 100644
--- a/src/Ursa/Controls/Pagination/Pagination.cs
+++ b/src/Ursa/Controls/Pagination/Pagination.cs
@@ -68,7 +68,7 @@ public class Pagination: TemplatedControl
}
public static readonly StyledProperty PageSizeProperty = AvaloniaProperty.Register(
- nameof(PageSize), defaultValue: 50);
+ nameof(PageSize), defaultValue: 10);
///
/// Page size.
@@ -144,7 +144,7 @@ public class Pagination: TemplatedControl
private void UpdateButtons()
{
if (PageSize == 0) return;
- int currentPage = CurrentPage;
+ int currentIndex = CurrentPage * PageSize;
int pageCount = TotalCount / PageSize;
int residue = TotalCount % PageSize;
@@ -162,7 +162,7 @@ public class Pagination: TemplatedControl
}
else
{
- _buttonPanel?.Children.Add(new Button { Content = i + 1 });
+ _buttonPanel?.Children.Add(new PaginationButton { Content = i + 1, Page = i + 1 });
}
}
}
diff --git a/src/Ursa/Controls/Pagination/PaginationButton.cs b/src/Ursa/Controls/Pagination/PaginationButton.cs
new file mode 100644
index 0000000..71bfeb1
--- /dev/null
+++ b/src/Ursa/Controls/Pagination/PaginationButton.cs
@@ -0,0 +1,14 @@
+using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
+using Avalonia.Styling;
+
+namespace Ursa.Controls;
+
+public class PaginationButton: Button, IStyleable
+{
+ Type IStyleable.StyleKey => typeof(Button);
+
+ public int Page { get; set; }
+
+
+}
\ No newline at end of file
diff --git a/src/Ursa/Controls/Pagination/PaginationExpandButton.cs b/src/Ursa/Controls/Pagination/PaginationExpandButton.cs
index ba330bb..fb50a59 100644
--- a/src/Ursa/Controls/Pagination/PaginationExpandButton.cs
+++ b/src/Ursa/Controls/Pagination/PaginationExpandButton.cs
@@ -1,11 +1,21 @@
using Avalonia;
using Avalonia.Collections;
+using Avalonia.Controls;
+using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
+using Avalonia.Input;
namespace Ursa.Controls;
+[TemplatePart(PART_Button, typeof(Button))]
+[TemplatePart(PART_Popup, typeof(Popup))]
public class PaginationExpandButton: TemplatedControl
{
+ public const string PART_Button = "PART_Button";
+ public const string PART_Popup = "PART_Popup";
+ private Popup? _popup;
+ private Button? _button;
+
public static readonly StyledProperty> PagesProperty = AvaloniaProperty.Register>(
nameof(Pages));
@@ -14,6 +24,56 @@ public class PaginationExpandButton: TemplatedControl
get => GetValue(PagesProperty);
set => SetValue(PagesProperty, value);
}
-
-
+
+ public static readonly StyledProperty IsDropdownOpenProperty = AvaloniaProperty.Register(
+ nameof(IsDropdownOpen));
+
+ public bool IsDropdownOpen
+ {
+ get => GetValue(IsDropdownOpenProperty);
+ set => SetValue(IsDropdownOpenProperty, value);
+ }
+
+ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
+ {
+ base.OnApplyTemplate(e);
+ _popup = e.NameScope.Find(PART_Popup);
+ _button = e.NameScope.Find