Tap and pinch gestures conflict

AndrewHoffmanAndrewHoffman USUniversity ✭✭

I have a page that has a grid that contains a dynamic number of controls within it and each control has it's own tap event. I need to be able to pinch on this grid to add or remove columns. On iOS this works perfectly well. However, on Android, the pinch gesture only works if it's done in an area of the screen where there are no controls. If I try to pinch over any of the controls, nothing happens. I added some debugging statements, and it doesn't look the pinch event is even fired. It almost appears as if the the controls are swallowing the finger down and not allowing the pinch to fire. The relevant code is posted below (the 'xxxx's are where I had to redact some of the code).


<ContentPage x:Class="xxxxx"

    <Grid RowSpacing="0">
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />

        <xxxxxx x:Name="xxxxx" Grid.Row="0" />

        <ScrollView Grid.Row="1">
            <Grid x:Name="ContentGrid"

The Constructor:

private PinchGestureRecognizer pinch;
public xxxxx()

     pinch = new PinchGestureRecognizer();

     pinch.PinchUpdated += Zoom;


Filling in the grid (I had to cut this down to only the relevant portion):

var tapGesture = new TapGestureRecognizer();
tapGesture.Tapped += OnCtrlTapped;

ContentGrid.Children.Add(ctrl, colIndex, rowIndex);

I didn't include the Zoom method because it works correctly when fired. The problem as mentioned above is that doesn't fire when the pinch occurs over the controls. Am I running up against a bug that I don't know about, or did I do something to cause the conflict?


  • DanielKokDanielKok NLUniversity ✭✭

    Did you ever find a solution for this? I am running into the same issue.

  • AndrewHoffmanAndrewHoffman USUniversity ✭✭

    What we ended up doing was placing another view over the Grid and proxying the gestures through.>

  • DanielKokDanielKok NLUniversity ✭✭

    Thanks Andrew. Could you elabaorate a bit more on how you did this, please? Did you write custom renderers to capture the touches of the overlay view and pass them on to underlying views?

  • AndrewHoffmanAndrewHoffman USUniversity ✭✭
    edited June 2019

    @DanielKok Unfortunately, I don't have access to that code base any more, but I'll try to describe it as best I can recall.
    1. We set up a custom control extending BoxView that included EventHandler's for each gesture we needed to capture and then registered TapGestureRecognizers on the BoxView and wired them up to invoke the events when they occurred with the correct args.
    2. Overlay that box on top of the controls that we were working on. In our case the controls were in a grid, so we added the BoxView to the grid last so it would be on top of the controls.
    3. Subscribe to the events from the BoxView on the view we were working on and then do whatever. For example for the tap event, we would get the correct X,Y coordinates from the tap gesture on the BoxView, send it in some custom event args we set up, and in the subscription, use those coordinates to determine what control needs it's tapped event fired.

    Sorry if that's not more clear. Trying to remember 2 year old code. :)

Sign In or Register to comment.