Reputation: 13
I'm quite new here and with xamarin.forms, so sorry if I miss something.
I'm using Xamarin.Forms 1.2.3.0 and writing this code PCL, using SV2012.
The problem is that I have a huge image as child in scrollview and i need to get coordinates where double tap was performed.
I'm using TapGestureRecognizer to handle click, but all that I achieved is that i get on click method called.
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += tapped;
void tapped(object sender, EventArgs e)
{
//I'm going to do some magic with image when i will have a point where i tapped
}
any ideas appreciated.
Upvotes: 1
Views: 220
Reputation: 2601
Short answer is, Xamarin Forms does not give you this out of the box, as you can guess already.
Longer answer -
You need to write yourself some custom platform specific code (i.e. which can get the Point data above using something like platform method LocationView(...) on IOS) using the Xamarin framework, either using a Custom Renderer or an Effect to hook up the platform specific code.
This is not trivial and pasting code here will not be useful.
Some good discussion and excellent github repositories here -
https://forums.xamarin.com/discussion/17767/touch-coordinates-in-tapgesturerecognizer http://mrgestures.com/ - 3rd party out of the box library (no affiliation and have not used yet) https://github.com/tkowalczyk/SimpleCustomGestureFrame https://github.com/softlion/XamarinFormsGesture/ - nice use of effect to add various gesture points
Should be enough to allow you to build or import a decent solution for this and other gestures.
Upvotes: 1