CarouselPageFirstLookPage.xaml.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections;
  2. using Avalonia.Controls;
  3. using Avalonia.Interactivity;
  4. namespace ControlCatalog.Pages
  5. {
  6. public partial class CarouselPageFirstLookPage : UserControl
  7. {
  8. public CarouselPageFirstLookPage()
  9. {
  10. InitializeComponent();
  11. }
  12. private void OnPrevious(object? sender, RoutedEventArgs e)
  13. {
  14. if (DemoCarousel.SelectedIndex > 0)
  15. DemoCarousel.SelectedIndex--;
  16. }
  17. private void OnNext(object? sender, RoutedEventArgs e)
  18. {
  19. var pageCount = (DemoCarousel.Pages as IList)?.Count ?? 0;
  20. if (DemoCarousel.SelectedIndex < pageCount - 1)
  21. DemoCarousel.SelectedIndex++;
  22. }
  23. private void OnSelectionChanged(object? sender, PageSelectionChangedEventArgs e)
  24. {
  25. if (StatusText == null)
  26. return;
  27. var pageCount = (DemoCarousel.Pages as IList)?.Count ?? 0;
  28. StatusText.Text = $"Page {DemoCarousel.SelectedIndex + 1} of {pageCount}";
  29. }
  30. }
  31. }