Forum Xamarin.Forms

Xamarin TapGestureRecognizer sometime does not work properly

LeLGLeLG Member ✭✭
edited April 2019 in Xamarin.Forms

I am currently building my mobile application using Xamarin.Forms and i encountered a problem (on both platform of ios and android) when i tried to use Xamarin.Forms gestures more particularly a tap gesture on a xaml Label. Because i want to use this label as a link.

The problem is that this tab gesture that i used does not work sometime ( approximately 5 times test = 1 time bug).

During DEBUG when the problem occured i see that the tabbing is still recognized but it did not respond in the action i set up.

It occurs on both iOS and Android devices.

Here is my XAML code:
<RelativeLayout> <Image Source="icon_question" WidthRequest="15" HeightRequest="15"></Image> <Label Margin="15, -3, 0, 0" HorizontalOptions="CenterAndExpand" HorizontalTextAlignment="Center" Text="Some text" TextColor="Blue" FontSize="15" TextDecorations="Underline"> <Label.GestureRecognizers> <TapGestureRecognizer Tapped="_tabLinkForgetPassword"></TapGestureRecognizer> </Label.GestureRecognizers> </Label> </RelativeLayout>

and here is my code behind:

private void _tabLinkForgetPassword(object s, EventArgs e) { App.Current.MainPage = new ResetPasswordPage(false); }

Answers

  • LeLGLeLG Member ✭✭

    @Gelatto i changed it and apply the Gesture to the , i have just find out that TapGestureRecognizer is applied to Label by pixels, so obviously that would cause some mis-click from time to time. Thank you for your answer.

Sign In or Register to comment.