Can CarouselView really replace CarouselPage control

SteveGSteveG NZMember ✭✭

Hi - previously asked this question on the cross platform forum by mistake. Reposting here as this is where it really applies.

Hope I'm not missing the point here and happy for someone to point me in the right direction.

I've been developing a little app that makes use of CarouselPage and that's worked pretty well (though there is that lurking concern about resource use and keeping number of pages as small as possible).

I see that CarouselView has now been released and I've had a go a couple of samples I've found and made my own. It's very nice.

The issue I see is that the CarouselView is GREAT for homogeneous content display, since it's basically the same as the listview concept. However, can you use it for heterogeneous content display? For example, when I use the CarouselPage, I'm adding pages to it that contain different layout / data than other pages. This question is really similar to what you'd consider when deciding to use a ListView or a TableView. Listview is great if data all share the same layout (template), if not, then use TableView.

If CarouselView is going to replace CarouselPage, is there a way to be able to use a CarouselView to display a list of "pages" that have different layouts? In other words, populate a collection with prebuilt pages and have the carouselview render them? I don't think I've ever seen that sort of binding before

At the end of the day all I'm after is a way to be able to "swipe" between a series of pages in Xamarin Forms. If someone can point me to an XF example of capturing the horizontal swipe gesture so that I could navigate between prebuilt pages then I could solve things that way.

Cheers

Steve

Answers

  • Greg.MGreg.M USMember

    Hi - you can use a DataTemplateSelector to change the controls in each "page" but I it seems if you want to have different displayable data for each page then it must ALL be accessible from each item in the ItemSource of the CarouselView (as the index to this changes for each page).

    I'm trying this ugly approach but whenever I try to bind to an object (list) in data templates I only get NULL? Strings work ok though.

    If you get any further I'd be interested to know.

  • Greg.MGreg.M USMember

    It seems that using ContentView could be the way to go. Take a look at the Demo app in the GitHub Repo for CarouselView:
    here https://github.com/alexrainman/CarouselView

  • tribaltribal USMember ✭✭✭
    edited December 2016

    Another way to go about using> @Greg.M said:

    Hi - you can use a DataTemplateSelector to change the controls in each "page" but I it seems if you want to have different displayable data for each page then it must ALL be accessible from each item in the ItemSource of the CarouselView (as the index to this changes for each page).

    I'm trying this ugly approach but whenever I try to bind to an object (list) in data templates I only get NULL? Strings work ok though.

    If you get any further I'd be interested to know.

    Oren Novotny has a good example of DataTemplateSelector here

Sign In or Register to comment.