我正在研究Xamarin Forms的功能,以尽可能高的水平处理屏幕交互-理想情况下,适用于iOS和Andoid的一组代码。我创建了一个新的XF应用程序(F#中的Multiplatform-> App,没有XAML),并将其添加到默认模板中:
type App() =
inherit Application()
let stack = StackLayout(VerticalOptions = LayoutOptions.Center)
let label = Label(XAlign = TextAlignment.Center, Text = "Welcome to F# Xamarin.Forms!")
do
let tapRecognizer = new TapGestureRecognizer()
let handleTapEvent (sender:Object) (args:EventArgs) =
label.Text <- "Tapped at " + DateTime.Now.ToString()
()
let tapEventHandler = new EventHandler(handleTapEvent)
tapRecognizer.Tapped.AddHandler(tapEventHandler)
label.GestureRecognizers.Add(tapRecognizer)
let doubleTapRecognizer = new TapGestureRecognizer()
doubleTapRecognizer.NumberOfTapsRequired <- 2
let handleDoubleTapEvent (sender:Object) (args:EventArgs) =
label.Text <- "Double Tapped at " + DateTime.Now.ToString()
()
let doubleTapEventHandler = new EventHandler(handleDoubleTapEvent)
doubleTapRecognizer.Tapped.AddHandler(doubleTapEventHandler)
label.GestureRecognizers.Add(doubleTapRecognizer)
stack.Children.Add(label)
base.MainPage <- ContentPage(Content = stack)
问题是点击仍然是双击的一部分。有没有办法识别点击或双击(相对于点击和双击)?
预先感谢