Xamarin.Forms Xamarin Gesture Gesture Event

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

When we put the control of Label, the Label does not provide any event. <Label x:Name="lblSignUp Text="Dont't have account?"/> as shown the Label only display purpose only.

When the user want to replace Button with Label, then we give the event for Label. As shown below:

XAML

<Label x:Name="lblSignUp" Text="Don't have an account?" Grid.Row="8" Grid.Column="1" Grid.ColumnSpan="2">
  <Label.GestureRecognizers>
    <TapGestureRecognizer
   Tapped="lblSignUp_Tapped"/>
  </Label.GestureRecognizers>

C#

var lblSignUp_Tapped = new TapGestureRecognizer();   
lblSignUp_Tapped.Tapped += (s,e) =>
{
//
//  Do your work here.
//
};
lblSignUp.GestureRecognizers.Add(lblSignUp_Tapped);

The Screen Below shown the Label Event. Screen 1 : The Label "Don't have an account?" as shown in Bottom . The Label "Don't have an account?" as shown in Bottom .

When the User click the Label "Don't have an account?", it will Navigate to Sign Up Screen. enter image description here For more details: [https://developer.xamarin.com/guides/xamarin-forms/user-interface/gestures/tap/][1]



Got any Xamarin.Forms Question?