How to handle the selection changed event in .NET MAUI Carousel?
This section explains how to handle the selection changed event in a .NET MAUI Carousel. You can perform specific operations when changing the CarouselItem using the SelectionChanged event. This event provides access to both the old and newly selected items.
XAML
<carousel:SfCarousel x:Name="carousel"
ItemsSource="{Binding ImageCollection}"
ItemHeight="200"
ItemWidth="200"
SelectionChanged="Carousel_SelectionChanged"/>
C#
private void Carousel_SelectionChanged(object sender, Syncfusion.Maui.Core.Carousel.SelectionChangedEventArgs e)
{
int count = (sender as SfCarousel).SelectedIndex + 1;
DisplayAlert("SelectionChanged", "Carousel item:" + count + " has Selected", "Ok");
}
Output
Conclusion
I hope you enjoyed learning how to handle the selection changed event in .NET MAUI Carousel.
Refer to our .NET MAUI Carousel feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI Carousel documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components on the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to explore our .NET MAUI Carousel and other .NET MAUI components.
Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal, or the feedback portal. We are always happy to assist you!