Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do Image Click Event works on Xamarin Forms - iOS Apps?

I am relatively new to Xamarin Forms : iOS Apps. Just like any other Apps, I have to create an event on an Image. Home , Back , Account setting.

Whether these events are fired on Image Button Event ?

like image 700
goofyui Avatar asked Nov 19 '16 03:11

goofyui


1 Answers

There is no click event for the image. You have to create a Tap Gesture Recognizer for the image.

Xaml:

<Image Source="imageName.png">
    <Image.GestureRecognizers>
        <TapGestureRecognizer
                Tapped="OnImageNameTapped"
                NumberOfTapsRequired="1" />
  </Image.GestureRecognizers>
</Image>

Xaml.cs:

void OnImageNameTapped(object sender, EventArgs args)
    {
        try
         {
            //Code to execute on tapped event
         }
        catch (Exception ex)
         {
           throw ex;
         }
    }
like image 166
Himanshu Dwivedi Avatar answered Oct 20 '22 03:10

Himanshu Dwivedi