Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine location of a tap in Xamarin Forms?

In Xamarin Forms how do I find out the location of a tap (within an image, say)?My code is:

var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += OnTapGestureRecognizerTapped;
image.GestureRecognizers.Add(tapGestureRecognizer);
...
...
void OnTapGestureRecognizerTapped(object sender, EventArgs args)
{ ... }

args.Parameter returns null (for iOS). I did not find any docs for Parameter. In the handler I tried changing EventArgs to TappedEventArgs but then did not compile. Also tried casting args to TappedEventArgs but that did not change anything.

like image 698
BillF Avatar asked Jun 07 '16 12:06

BillF


People also ask

How do I use xamarin community toolkit?

Setup Xamarin Community ToolkitOpen an existing project, or create a new project using the Blank Forms App template. In the Solution Explorer panel, right click on your project name and select Manage NuGet Packages. Search for Xamarin. CommunityToolkit, and choose the desired NuGet Package from the list.


1 Answers

At the moment of writing this answer it seems that there is no way of receiving the coordinates of the tap in XamarinForms without platform specific code. There are third party libraries (mentioned here) which provide this information.

like image 108
Pavel Pavlov Avatar answered Sep 22 '22 12:09

Pavel Pavlov