LocationInView等效于xamarin.forms

时间:2014-11-18 10:50:55

标签: c# xamarin.forms

我在这里和xamarin.forms很新,很抱歉,如果我错过了什么。

我正在使用Xamarin.Forms 1.2.3.0并使用SV2012编写此代码PCL。

问题是我在scrollview中有一个巨大的图像作为孩子,我需要获得执行双击的坐标。

我正在使用TapGestureRecognizer来处理点击,但我所取得的就是点击方法。

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
}

任何赞赏的想法。

1 个答案:

答案 0 :(得分:1)

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.