From 7512fa4bd0e2ad40adb006bb5816f91afb0f35aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Wed, 18 Mar 2026 14:13:52 +0100 Subject: [PATCH] Added more Carousel samples (#20932) * Added all the Carousel samples * Fixes * Updated sample * More changes --- samples/ControlCatalog/MainView.xaml | 6 +- .../Pages/CarouselDemoPage.xaml | 11 + .../Pages/CarouselDemoPage.xaml.cs | 53 ++ .../CarouselCustomizationPage.xaml | 119 ++++ .../CarouselCustomizationPage.xaml.cs | 48 ++ .../CarouselPage/CarouselDataBindingPage.xaml | 60 ++ .../CarouselDataBindingPage.xaml.cs | 95 +++ .../CarouselPage/CarouselGalleryAppPage.xaml | 557 ++++++++++++++++++ .../CarouselGalleryAppPage.xaml.cs | 101 ++++ .../CarouselPage/CarouselGesturesPage.xaml | 93 +++ .../CarouselPage/CarouselGesturesPage.xaml.cs | 59 ++ .../CarouselGettingStartedPage.xaml | 74 +++ .../CarouselGettingStartedPage.xaml.cs | 40 ++ .../CarouselPage/CarouselMultiItemPage.xaml | 140 +++++ .../CarouselMultiItemPage.xaml.cs | 47 ++ .../CarouselPage/CarouselTransitionsPage.xaml | 97 +++ .../CarouselTransitionsPage.xaml.cs | 66 +++ .../CarouselPage/CarouselVerticalPage.xaml | 132 +++++ .../CarouselPage/CarouselVerticalPage.xaml.cs | 39 ++ .../VirtualizingCarouselPanel.cs | 14 +- 20 files changed, 1848 insertions(+), 3 deletions(-) create mode 100644 samples/ControlCatalog/Pages/CarouselDemoPage.xaml create mode 100644 samples/ControlCatalog/Pages/CarouselDemoPage.xaml.cs create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselCustomizationPage.xaml create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselCustomizationPage.xaml.cs create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselDataBindingPage.xaml create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselDataBindingPage.xaml.cs create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselGalleryAppPage.xaml create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselGalleryAppPage.xaml.cs create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselGesturesPage.xaml create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselGesturesPage.xaml.cs create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselGettingStartedPage.xaml create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselGettingStartedPage.xaml.cs create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselMultiItemPage.xaml create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselMultiItemPage.xaml.cs create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselTransitionsPage.xaml create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselTransitionsPage.xaml.cs create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselVerticalPage.xaml create mode 100644 samples/ControlCatalog/Pages/CarouselPage/CarouselVerticalPage.xaml.cs diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index b6249fe17f..2a0de7a114 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -54,8 +54,10 @@ ScrollViewer.VerticalScrollBarVisibility="Disabled"> - - + + diff --git a/samples/ControlCatalog/Pages/CarouselDemoPage.xaml b/samples/ControlCatalog/Pages/CarouselDemoPage.xaml new file mode 100644 index 0000000000..df4317fcad --- /dev/null +++ b/samples/ControlCatalog/Pages/CarouselDemoPage.xaml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/samples/ControlCatalog/Pages/CarouselDemoPage.xaml.cs b/samples/ControlCatalog/Pages/CarouselDemoPage.xaml.cs new file mode 100644 index 0000000000..64753b9fc4 --- /dev/null +++ b/samples/ControlCatalog/Pages/CarouselDemoPage.xaml.cs @@ -0,0 +1,53 @@ +using System; +using Avalonia.Controls; +using Avalonia.Interactivity; + +namespace ControlCatalog.Pages +{ + public partial class CarouselDemoPage : UserControl + { + private static readonly (string Group, string Title, string Description, Func Factory)[] Demos = + { + // Overview + ("Overview", "Getting Started", + "Basic Carousel with image items and previous/next navigation buttons.", + () => new CarouselGettingStartedPage()), + + // Features + ("Features", "Transitions", + "Configure page transitions: PageSlide, CrossFade, 3D Rotation, or None.", + () => new CarouselTransitionsPage()), + ("Features", "Customization", + "Adjust orientation and transition type to tailor the carousel layout.", + () => new CarouselCustomizationPage()), + ("Features", "Gestures & Keyboard", + "Navigate items via swipe gesture and arrow keys. Toggle each input mode on and off.", + () => new CarouselGesturesPage()), + ("Features", "Vertical Orientation", + "Carousel with Orientation set to Vertical, navigated with Up/Down keys, swipe, or buttons.", + () => new CarouselVerticalPage()), + ("Features", "Multi-Item Peek", + "Adjust ViewportFraction to show multiple items simultaneously with adjacent cards peeking.", + () => new CarouselMultiItemPage()), + ("Features", "Data Binding", + "Bind Carousel to an ObservableCollection and add, remove, or shuffle items at runtime.", + () => new CarouselDataBindingPage()), + + // Showcases + ("Showcases", "Curated Gallery", + "Editorial art gallery app with DrawerPage navigation, hero Carousel with PipsPager dots, and a horizontal peek carousel for collection highlights.", + () => new CarouselGalleryAppPage()), + }; + + public CarouselDemoPage() + { + InitializeComponent(); + Loaded += OnLoaded; + } + + private async void OnLoaded(object? sender, RoutedEventArgs e) + { + await SampleNav.PushAsync(NavigationDemoHelper.CreateGalleryHomePage(SampleNav, Demos), null); + } + } +} diff --git a/samples/ControlCatalog/Pages/CarouselPage/CarouselCustomizationPage.xaml b/samples/ControlCatalog/Pages/CarouselPage/CarouselCustomizationPage.xaml new file mode 100644 index 0000000000..add442e7a1 --- /dev/null +++ b/samples/ControlCatalog/Pages/CarouselPage/CarouselCustomizationPage.xaml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +