Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Tap and pinch gestures conflict

$
0
0

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).

The XAML:

<ContentPage x:Class="xxxxx"
         xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">

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

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

        <ScrollView Grid.Row="1">
            <Grid x:Name="ContentGrid"
                  ColumnSpacing="4"
                  RowSpacing="4"/>
        </ScrollView>
    </Grid>
</ContentPage>

The Constructor:

private PinchGestureRecognizer pinch;
public xxxxx()
{         
     InitializeComponent();

     pinch = new PinchGestureRecognizer();

     pinch.PinchUpdated += Zoom;

     ContentGrid.GestureRecognizers.Add(pinch);          
 }

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

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

ctrl.GestureRecognizers.Add(tapGesture);
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?


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>