Merge pull request #182 from Soar360/main

为 Pagination 控件增加 CurrentPageChanged 事件
This commit is contained in:
Dong Bin
2024-03-25 09:49:34 +08:00
committed by GitHub
3 changed files with 86 additions and 20 deletions

View File

@@ -24,6 +24,8 @@
PageSizeOptions="10, 20, 50, 100"
ShowQuickJump="{Binding #quickJumperSelector.IsChecked}"
ShowPageSizeSelector="{Binding #pageSizeSelector.IsChecked}"
Command="{Binding LoadPageCommand}"
CommandParameter="{Binding $self.CurrentPage}"
TotalCount="600" />
</StackPanel>
</UserControl>

View File

@@ -1,11 +1,25 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows.Input;
using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace Ursa.Demo.ViewModels;
public class PaginationDemoViewModel: ViewModelBase
public class PaginationDemoViewModel : ViewModelBase
{
public AvaloniaList<int> PageSizes { get; set; } = new() { 10, 20, 50, 100 };
public ICommand LoadPageCommand { get; }
public PaginationDemoViewModel()
{
this.LoadPageCommand = new RelayCommand<int?>(LoadPage);
}
private void LoadPage(int? pageIndex)
{
Debug.WriteLine($"Loading page {pageIndex}");
}
}