Search code examples
listviewxamarinxamarin.formsgesture-recognitionxamarin.winphone

How do I let the user swipe a CarouselPage when it contains a ListView?


In my Xamarin.Forms app for Windows Phone 8.1, we have a number of pages that the user can swipe between using a CarouselPage. One of these pages contains a ListView that fills the screen, and when that page selected the user can't swipe any more; the action is interpreted by the list view as a tap in one of its cells. What can I do so that horizontal swipes will still change page in the carousel? I still want vertical swipes to scroll the list view.


Solution

  • This can not be directly achieved in the Xamarin Forms project because when there is a list view available all the taps, gestures, etc will handled by the listview itself. Only the gestures which are not handled by the top most layout/control will be passed into the controls/layouts beneath it. So in your case the listview handles all the gestures and nothing is passed to your carousel page.

    The only work around for the problem that I can think of is, setting the InputTransparent property of the listview as true. In that case no gestures will be handled by the listview and everything will be passed on to the carousel page. But since you need to have the selected item and open the detail page from the list view, what you can do is have a button in the listview item template and handle the click of the button. Since button is a separate control and on top of listview, the setting InputTransparent wont affect the button click event/command binding.

    EDIT : As per OP's experience he is able to access the selected item and all other features of listview even after setting the InputTransparent.