From b0c86e91a112d0bb1c93d9d944f165fc8336215b Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sat, 10 Aug 2024 00:17:36 +0800 Subject: [PATCH 1/6] feat: add CurrentPage coercion. --- src/Ursa/Controls/Pagination/Pagination.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Ursa/Controls/Pagination/Pagination.cs b/src/Ursa/Controls/Pagination/Pagination.cs index cac9b54..acdd98a 100644 --- a/src/Ursa/Controls/Pagination/Pagination.cs +++ b/src/Ursa/Controls/Pagination/Pagination.cs @@ -33,13 +33,23 @@ public class Pagination: TemplatedControl private NumericIntUpDown? _quickJumpInput; public static readonly StyledProperty CurrentPageProperty = AvaloniaProperty.Register( - nameof(CurrentPage)); - + nameof(CurrentPage) , coerce: CoerceCurrentPage); + public int? CurrentPage { get => GetValue(CurrentPageProperty); set => SetValue(CurrentPageProperty, value); } + + private static int? CoerceCurrentPage(AvaloniaObject arg1, int? arg2) + { + if (arg2 is null) return null; + if (arg1 is Pagination p) + { + arg2 = MathHelpers.SafeClamp(arg2.Value, 1, p.PageCount + 1); + } + return arg2; + } private void OnCurrentPageChanged(AvaloniaPropertyChangedEventArgs args) { From d8740e540b07c770fad9bbe3fcf97b9b6314b795 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sat, 10 Aug 2024 00:42:06 +0800 Subject: [PATCH 2/6] feat: add tiny theme. --- demo/Ursa.Demo/Pages/PaginationDemo.axaml | 3 + .../Controls/Pagination.axaml | 97 +++++++++++++++---- src/Ursa/Controls/Pagination/Pagination.cs | 2 +- 3 files changed, 84 insertions(+), 18 deletions(-) diff --git a/demo/Ursa.Demo/Pages/PaginationDemo.axaml b/demo/Ursa.Demo/Pages/PaginationDemo.axaml index a90dfbe..24505aa 100644 --- a/demo/Ursa.Demo/Pages/PaginationDemo.axaml +++ b/demo/Ursa.Demo/Pages/PaginationDemo.axaml @@ -28,5 +28,8 @@ 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..a46029a 100644 --- a/src/Ursa.Themes.Semi/Controls/Pagination.axaml +++ b/src/Ursa.Themes.Semi/Controls/Pagination.axaml @@ -8,31 +8,42 @@ - + - + - - + + - + - + - - + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + \ No newline at end of file diff --git a/src/Ursa/Controls/Pagination/Pagination.cs b/src/Ursa/Controls/Pagination/Pagination.cs index acdd98a..0b5a9ae 100644 --- a/src/Ursa/Controls/Pagination/Pagination.cs +++ b/src/Ursa/Controls/Pagination/Pagination.cs @@ -46,7 +46,7 @@ public class Pagination: TemplatedControl if (arg2 is null) return null; if (arg1 is Pagination p) { - arg2 = MathHelpers.SafeClamp(arg2.Value, 1, p.PageCount + 1); + arg2 = MathHelpers.SafeClamp(arg2.Value, 1, p.PageCount); } return arg2; } From 69f72238a6bb457e6c3d5ae240022160f9b04b72 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sat, 10 Aug 2024 01:00:30 +0800 Subject: [PATCH 3/6] feat: add readonly mode. --- src/Ursa.Themes.Semi/Controls/Pagination.axaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Ursa.Themes.Semi/Controls/Pagination.axaml b/src/Ursa.Themes.Semi/Controls/Pagination.axaml index a46029a..e6a1959 100644 --- a/src/Ursa.Themes.Semi/Controls/Pagination.axaml +++ b/src/Ursa.Themes.Semi/Controls/Pagination.axaml @@ -75,11 +75,13 @@ + @@ -99,6 +101,12 @@ + + Date: Sat, 10 Aug 2024 12:50:42 +0800 Subject: [PATCH 4/6] feat: improve readonly mode. --- demo/Ursa.Demo/Pages/PaginationDemo.axaml | 1 + .../Controls/Pagination.axaml | 108 ++++++++---------- .../Controls/Pagination/PaginationButton.cs | 2 +- 3 files changed, 50 insertions(+), 61 deletions(-) diff --git a/demo/Ursa.Demo/Pages/PaginationDemo.axaml b/demo/Ursa.Demo/Pages/PaginationDemo.axaml index 24505aa..458a2e4 100644 --- a/demo/Ursa.Demo/Pages/PaginationDemo.axaml +++ b/demo/Ursa.Demo/Pages/PaginationDemo.axaml @@ -31,5 +31,6 @@ + diff --git a/src/Ursa.Themes.Semi/Controls/Pagination.axaml b/src/Ursa.Themes.Semi/Controls/Pagination.axaml index e6a1959..908f16b 100644 --- a/src/Ursa.Themes.Semi/Controls/Pagination.axaml +++ b/src/Ursa.Themes.Semi/Controls/Pagination.axaml @@ -8,44 +8,36 @@ - + - + - - + + - + + Width="50" + ShowButtonSpinner="False" /> @@ -59,39 +51,45 @@ - + - + - + - - + VerticalAlignment="Center" + HorizontalContentAlignment="Center" + ShowButtonSpinner="False" + IsVisible="True" + Value="{TemplateBinding CurrentPage, + Mode=TwoWay}" /> + + - - + Grid.Column="2" + VerticalAlignment="Center" + Text="{TemplateBinding PageCount}" /> + + - - - + + - - + + - + diff --git a/src/Ursa/Controls/Pagination/PaginationButton.cs b/src/Ursa/Controls/Pagination/PaginationButton.cs index b05babc..aef8b4d 100644 --- a/src/Ursa/Controls/Pagination/PaginationButton.cs +++ b/src/Ursa/Controls/Pagination/PaginationButton.cs @@ -5,7 +5,7 @@ using Avalonia.Controls.Metadata; namespace Ursa.Controls; [PseudoClasses(PC_Left, PC_Right, PC_Selected)] -public class PaginationButton: Button +public class PaginationButton: RepeatButton { public const string PC_Left = ":left"; public const string PC_Right = ":right"; From 378c5b020080f8c7c1eef40a8520203e05ed8142 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sat, 10 Aug 2024 13:37:35 +0800 Subject: [PATCH 5/6] fix: make sure page count is properly calculated even if template is not loaded. --- demo/Ursa.Demo/Pages/PaginationDemo.axaml | 3 ++- src/Ursa/Controls/Pagination/Pagination.cs | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/demo/Ursa.Demo/Pages/PaginationDemo.axaml b/demo/Ursa.Demo/Pages/PaginationDemo.axaml index 458a2e4..22d4ebc 100644 --- a/demo/Ursa.Demo/Pages/PaginationDemo.axaml +++ b/demo/Ursa.Demo/Pages/PaginationDemo.axaml @@ -30,7 +30,8 @@ TotalCount="600" /> - + diff --git a/src/Ursa/Controls/Pagination/Pagination.cs b/src/Ursa/Controls/Pagination/Pagination.cs index 0b5a9ae..4fa4c15 100644 --- a/src/Ursa/Controls/Pagination/Pagination.cs +++ b/src/Ursa/Controls/Pagination/Pagination.cs @@ -114,8 +114,9 @@ public class Pagination: TemplatedControl private int _pageCount; - public static readonly DirectProperty PageCountProperty = AvaloniaProperty.RegisterDirect( - nameof(PageCount), o => o.PageCount); + public static readonly DirectProperty PageCountProperty = + AvaloniaProperty.RegisterDirect( + nameof(PageCount), o => o.PageCount, (o, e) => o.PageCount = e); /// /// Page count. @@ -291,11 +292,14 @@ public class Pagination: TemplatedControl /// private void UpdateButtonsByCurrentPage(int? page) { - if (_buttonPanel is null) return; if (PageSize == 0) return; - - int? currentPage = CurrentPage; int pageCount = TotalCount / PageSize; + if (_buttonPanel is null) + { + SetCurrentValue(PageCountProperty, pageCount); + return; + } + int? currentPage = CurrentPage; int residue = TotalCount % PageSize; if (residue > 0) { @@ -360,7 +364,7 @@ public class Pagination: TemplatedControl } } - PageCount = pageCount; + SetCurrentValue(PageCountProperty, pageCount); SetCurrentValue(CurrentPageProperty, currentPage); if (_previousButton != null) _previousButton.IsEnabled = (CurrentPage ?? int.MaxValue) > 1; if (_nextButton != null) _nextButton.IsEnabled = (CurrentPage ?? 0) < PageCount; From d5fc912a5d7abc33b02f773e447e3f3b007df0bc Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sat, 10 Aug 2024 13:45:38 +0800 Subject: [PATCH 6/6] feat: ensure TinyPagination invokes command. --- .../Controls/Pagination.axaml | 5 +- src/Ursa/Controls/Pagination/Pagination.cs | 335 +++++++++--------- 2 files changed, 162 insertions(+), 178 deletions(-) diff --git a/src/Ursa.Themes.Semi/Controls/Pagination.axaml b/src/Ursa.Themes.Semi/Controls/Pagination.axaml index 908f16b..6b2eeca 100644 --- a/src/Ursa.Themes.Semi/Controls/Pagination.axaml +++ b/src/Ursa.Themes.Semi/Controls/Pagination.axaml @@ -52,6 +52,7 @@ + @@ -64,7 +65,7 @@ - diff --git a/src/Ursa/Controls/Pagination/Pagination.cs b/src/Ursa/Controls/Pagination/Pagination.cs index 4fa4c15..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,165 +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) , coerce: CoerceCurrentPage); - - public int? CurrentPage - { - get => GetValue(CurrentPageProperty); - set => SetValue(CurrentPageProperty, value); - } - - private static int? CoerceCurrentPage(AvaloniaObject arg1, int? arg2) - { - if (arg2 is null) return null; - if (arg1 is Pagination p) - { - arg2 = MathHelpers.SafeClamp(arg2.Value, 1, p.PageCount); - } - return arg2; - } - - 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 CommandParameterProperty = AvaloniaProperty.Register(nameof(CommandParameter)); - - public object? CommandParameter - { - get => this.GetValue(CommandParameterProperty); - set => this.SetValue(CommandParameterProperty, value); - } + public static readonly StyledProperty CommandParameterProperty = + AvaloniaProperty.Register(nameof(CommandParameter)); public static readonly StyledProperty TotalCountProperty = AvaloniaProperty.Register( nameof(TotalCount)); - /// - /// Total count of items. - /// - public int TotalCount - { - get => GetValue(TotalCountProperty); - set => SetValue(TotalCountProperty, value); - } - public static readonly StyledProperty PageSizeProperty = AvaloniaProperty.Register( - nameof(PageSize), defaultValue: 10); - - /// - /// Page size. - /// - public int PageSize - { - get => GetValue(PageSizeProperty); - set => SetValue(PageSizeProperty, value); - } - - private int _pageCount; + nameof(PageSize), 10); public static readonly DirectProperty PageCountProperty = AvaloniaProperty.RegisterDirect( nameof(PageCount), o => o.PageCount, (o, e) => o.PageCount = e); - /// - /// Page count. - /// - public int PageCount - { - get => _pageCount; - private set => SetAndRaise(PageCountProperty, ref _pageCount, value); - } + public static readonly StyledProperty> PageSizeOptionsProperty = + AvaloniaProperty.Register>( + nameof(PageSizeOptions)); - public static readonly StyledProperty> PageSizeOptionsProperty = AvaloniaProperty.Register>( - nameof(PageSizeOptions)); + public static readonly StyledProperty PageButtonThemeProperty = + AvaloniaProperty.Register( + nameof(PageButtonTheme)); - public AvaloniaList PageSizeOptions - { - get => GetValue(PageSizeOptionsProperty); - set => SetValue(PageSizeOptionsProperty, value); - } - - public static readonly StyledProperty PageButtonThemeProperty = AvaloniaProperty.Register( - nameof(PageButtonTheme)); - - public ControlTheme PageButtonTheme - { - get => GetValue(PageButtonThemeProperty); - set => SetValue(PageButtonThemeProperty, value); - } - - public static readonly StyledProperty ShowPageSizeSelectorProperty = AvaloniaProperty.Register( - nameof(ShowPageSizeSelector)); - - public bool ShowPageSizeSelector - { - get => GetValue(ShowPageSizeSelectorProperty); - set => SetValue(ShowPageSizeSelectorProperty, value); - } + public static readonly StyledProperty ShowPageSizeSelectorProperty = + AvaloniaProperty.Register( + nameof(ShowPageSizeSelector)); public static readonly StyledProperty ShowQuickJumpProperty = AvaloniaProperty.Register( nameof(ShowQuickJump)); - public bool ShowQuickJump - { - get => GetValue(ShowQuickJumpProperty); - set => SetValue(ShowQuickJumpProperty, value); - } + private readonly PaginationButton[] _buttons = new PaginationButton[7]; + private StackPanel? _buttonPanel; + private PaginationButton? _nextButton; + + private int _pageCount; + private PaginationButton? _previousButton; + private NumericIntUpDown? _quickJumpInput; static Pagination() { - PageSizeProperty.Changed.AddClassHandler((pagination, args) => pagination.OnPageSizeChanged(args)); + PageSizeProperty.Changed.AddClassHandler((pagination, args) => + pagination.OnPageSizeChanged(args)); CurrentPageProperty.Changed.AddClassHandler((pagination, args) => pagination.UpdateButtonsByCurrentPage(args.NewValue.Value)); CurrentPageProperty.Changed.AddClassHandler((pagination, args) => @@ -174,19 +85,119 @@ public class Pagination: TemplatedControl pagination.UpdateButtonsByCurrentPage(pagination.CurrentPage)); } + public int? CurrentPage + { + get => GetValue(CurrentPageProperty); + set => SetValue(CurrentPageProperty, value); + } + + public ICommand? Command + { + get => GetValue(CommandProperty); + set => SetValue(CommandProperty, value); + } + + public object? CommandParameter + { + get => GetValue(CommandParameterProperty); + set => SetValue(CommandParameterProperty, value); + } + + /// + /// Total count of items. + /// + public int TotalCount + { + get => GetValue(TotalCountProperty); + set => SetValue(TotalCountProperty, value); + } + + /// + /// Page size. + /// + public int PageSize + { + get => GetValue(PageSizeProperty); + set => SetValue(PageSizeProperty, value); + } + + /// + /// Page count. + /// + public int PageCount + { + get => _pageCount; + private set => SetAndRaise(PageCountProperty, ref _pageCount, value); + } + + public AvaloniaList PageSizeOptions + { + get => GetValue(PageSizeOptionsProperty); + set => SetValue(PageSizeOptionsProperty, value); + } + + public ControlTheme PageButtonTheme + { + get => GetValue(PageButtonThemeProperty); + set => SetValue(PageButtonThemeProperty, value); + } + + public bool ShowPageSizeSelector + { + get => GetValue(ShowPageSizeSelectorProperty); + set => SetValue(ShowPageSizeSelectorProperty, value); + } + + public bool ShowQuickJump + { + get => GetValue(ShowQuickJumpProperty); + set => SetValue(ShowQuickJumpProperty, value); + } + + public static readonly StyledProperty DisplayCurrentPageInQuickJumperProperty = AvaloniaProperty.Register( + nameof(DisplayCurrentPageInQuickJumper)); + + public bool DisplayCurrentPageInQuickJumper + { + get => GetValue(DisplayCurrentPageInQuickJumperProperty); + set => SetValue(DisplayCurrentPageInQuickJumperProperty, value); + } + + private static int? CoerceCurrentPage(AvaloniaObject arg1, int? arg2) + { + if (arg2 is null) return null; + if (arg1 is Pagination p) arg2 = MathHelpers.SafeClamp(arg2.Value, 1, p.PageCount); + return arg2; + } + + private void OnCurrentPageChanged(AvaloniaPropertyChangedEventArgs args) + { + var oldValue = args.GetOldValue(); + var newValue = args.GetNewValue(); + var e = new ValueChangedEventArgs(CurrentPageChangedEvent, oldValue, newValue); + if (DisplayCurrentPageInQuickJumper) + { + _quickJumpInput?.SetCurrentValue(NumericIntUpDown.ValueProperty, newValue); + } + RaiseEvent(e); + } + + /// + /// Raised when the changes. + /// + public event EventHandler>? CurrentPageChanged + { + add => AddHandler(CurrentPageChangedEvent, value); + remove => RemoveHandler(CurrentPageChangedEvent, value); + } + private void OnPageSizeChanged(AvaloniaPropertyChangedEventArgs args) { - int pageCount = TotalCount / args.NewValue.Value; - int residue = TotalCount % args.NewValue.Value; - if (residue > 0) - { - pageCount++; - } + var pageCount = TotalCount / args.NewValue.Value; + var residue = TotalCount % args.NewValue.Value; + if (residue > 0) pageCount++; PageCount = pageCount; - if (CurrentPage > PageCount) - { - CurrentPage = null; - } + if (CurrentPage > PageCount) CurrentPage = null; UpdateButtonsByCurrentPage(CurrentPage); } @@ -212,10 +223,7 @@ public class Pagination: TemplatedControl private void OnQuickJumpInputKeyDown(object? sender, KeyEventArgs e) { - if (e.Key is Key.Enter or Key.Return) - { - SyncQuickJumperValue(); - } + if (e.Key is Key.Enter or Key.Return) SyncQuickJumperValue(); } private void OnQuickJumpInputLostFocus(object? sender, RoutedEventArgs e) @@ -230,7 +238,10 @@ public class Pagination: TemplatedControl if (value is null) return; value = Clamp(value.Value, 1, PageCount); SetCurrentValue(CurrentPageProperty, value); - _quickJumpInput?.SetCurrentValue(NumericIntUpDown.ValueProperty, null); + if (!DisplayCurrentPageInQuickJumper) + { + _quickJumpInput?.SetCurrentValue(NumericIntUpDown.ValueProperty, null); + } InvokeCommand(); } @@ -245,9 +256,9 @@ public class Pagination: TemplatedControl { if (_buttonPanel is null) return; _buttonPanel.Children.Clear(); - for (int i = 1; i <= 7; i++) + for (var i = 1; i <= 7; i++) { - var button = new PaginationButton() { Page = i, IsVisible = true }; + var button = new PaginationButton { Page = i, IsVisible = true }; _buttonPanel.Children.Add(button); _buttons[i - 1] = button; Button.ClickEvent.AddHandler(OnPageButtonClick, button); @@ -259,24 +270,19 @@ public class Pagination: TemplatedControl if (sender is PaginationButton pageButton) { if (pageButton.IsFastForward) - { AddCurrentPage(-5); - } else if (pageButton.IsFastBackward) - { AddCurrentPage(5); - } else - { CurrentPage = pageButton.Page; - } } + InvokeCommand(); } private void AddCurrentPage(int pageChange) { - int newValue = (CurrentPage ?? 0) + pageChange; + var newValue = (CurrentPage ?? 0) + pageChange; newValue = Clamp(newValue, 1, PageCount); SetCurrentValue(CurrentPageProperty, newValue); } @@ -287,29 +293,26 @@ public class Pagination: TemplatedControl } /// - /// Update Button Content and Visibility by current page. + /// Update Button Content and Visibility by current page. /// /// private void UpdateButtonsByCurrentPage(int? page) { if (PageSize == 0) return; - int pageCount = TotalCount / PageSize; + var pageCount = TotalCount / PageSize; if (_buttonPanel is null) { SetCurrentValue(PageCountProperty, pageCount); return; } - int? currentPage = CurrentPage; - int residue = TotalCount % PageSize; - if (residue > 0) - { - pageCount++; - } + + var currentPage = CurrentPage; + var residue = TotalCount % PageSize; + if (residue > 0) pageCount++; if (pageCount <= 7) { - for (int i = 0; i < 7; i++) - { + for (var i = 0; i < 7; i++) if (i < pageCount) { _buttons[i].IsVisible = true; @@ -319,15 +322,11 @@ public class Pagination: TemplatedControl { _buttons[i].IsVisible = false; } - } } else { - for (int i = 0; i < 7; i++) - { - _buttons[i].IsVisible = true; - } - int mid = currentPage ?? 0; + for (var i = 0; i < 7; i++) _buttons[i].IsVisible = true; + var mid = currentPage ?? 0; mid = Clamp(mid, 4, pageCount - 3); _buttons[3].Page = mid; _buttons[2].Page = mid - 1; @@ -335,33 +334,19 @@ public class Pagination: TemplatedControl _buttons[0].Page = 1; _buttons[6].Page = pageCount; if (mid > 4) - { _buttons[1].SetStatus(-1, false, true, false); - } else - { _buttons[1].SetStatus(mid - 2, false, false, false); - } if (mid < pageCount - 3) - { _buttons[5].SetStatus(-1, false, false, true); - } else - { _buttons[5].SetStatus(mid + 2, false, false, false); - } foreach (var button in _buttons) - { if (button.Page == currentPage) - { button.SetSelected(true); - } else - { button.SetSelected(false); - } - } } SetCurrentValue(PageCountProperty, pageCount); @@ -369,11 +354,9 @@ public class Pagination: TemplatedControl if (_previousButton != null) _previousButton.IsEnabled = (CurrentPage ?? int.MaxValue) > 1; if (_nextButton != null) _nextButton.IsEnabled = (CurrentPage ?? 0) < PageCount; } + private void InvokeCommand() { - if (this.Command != null && this.Command.CanExecute(this.CommandParameter)) - { - this.Command.Execute(this.CommandParameter); - } + if (Command != null && Command.CanExecute(CommandParameter)) Command.Execute(CommandParameter); } } \ No newline at end of file