4

I'm using CarouselPage class to implement Horizontal Slider in Xamarin.Forms. I am going to make CarouselPage class to move to the next page from tapping on the page, not swiping.

Is it possible? Can anyone help me?

Thanks in advance.

Fenix
  • 1,552
  • 2
  • 23
  • 44

1 Answers1

15

You could add a TapGestureRecognizer to your Page and wire it up to change the CurrentPage of the CarouselPage. Below is an extension method I wrote to move the current page index of a CarouselPage to the right. Calling this method from a TapGestureRecognizer connected to a child page should give you the desired functionality.

public static void PageRight(this CarouselPage carouselPage)
{
    var pageCount = carouselPage.Children.Count;
    if (pageCount < 2) 
        return;

    var index = carouselPage.Children.IndexOf(carouselPage.CurrentPage);
    index++;
    if (index >= pageCount) 
        index = 0;

    carouselPage.CurrentPage = carouselPage.Children[index];
}
Will Decker
  • 3,216
  • 20
  • 30