I have a Xamarin.Forms app that displays a ViewFlipper (https://github.com/TorbenK/ViewFlipper) inside a CarouselView.
I would like the ViewFlipper to flip back to the front when changing pages inside the carousel. But I can't seem to figure out how to access the ViewFlipper.
I have the following working code:
public class CarouselContent { public string FrontImg { get; set; } public string BackImg { get; set; } } public class MainPage : ContentPage { public MainPage() { var pages = new ObservableCollection<CarouselContent>(); var page1 = new CarouselContent(); page1.FrontImg = "page1Front"; page1.BackImg = "page1Back"; var page2 = new CarouselContent(); page2.FrontImg = "page2Front"; page2.BackImg = "page2Back"; pages.Add(page1); pages.Add(page2); var carouselView = new Carousel(pages); Content = carouselView; } } public class Carousel : AbsoluteLayout { private DotButtonsLayout dotLayout; private CarouselView carousel; public Carousel(ObservableCollection<CarouselContent> pages) { carousel = new CarouselView(); var template = new DataTemplate(() => { //create page var absLayout = new AbsoluteLayout(); //create images for the flipper var frontImg = new Image { Aspect = Aspect.AspectFit }; frontImg.SetBinding(Image.SourceProperty, "FrontImg"); var backImg = new Image { Aspect = Aspect.AspectFit }; backImg.SetBinding(Image.SourceProperty, "BackImg"); //create flipper var flipper = new ViewFlipper.FormsPlugin.Abstractions.ViewFlipper(); flipper.FrontView = frontImg; flipper.BackView = backImg; //Add flipper to page absLayout.Children.Add(flipper); return absLayout; }); carousel.ItemsSource = pages; carousel.ItemTemplate = template; Children.Add(carousel); } }
I tried adding the ViewFlipper to the CarouselContent but I couldn't get that to work. Any ideas?