Image Xamarin表单:如何为图像添加单点击和双点击?

Image Xamarin表单:如何为图像添加单点击和双点击?,image,xamarin.forms,gesture-recognition,Image,Xamarin.forms,Gesture Recognition,我正在尝试实现一个键盘用户界面。在键盘中,将+(加号)和0(零)选项放置在单个图像图标上。因此,对于单点击,我需要在UI上显示0,对于双点击,我需要在UI上显示+ 我的代码 <Image Grid.Column="1" Source="ic_zero_xx.png" Style="{StaticResource KeypadImageStyle}"> <Image.GestureRec

我正在尝试实现一个键盘用户界面。在键盘中,将+(加号)0(零)选项放置在单个图像图标上。因此,对于单点击,我需要在UI上显示0,对于双点击,我需要在UI上显示+

我的代码

<Image 
    Grid.Column="1"
    Source="ic_zero_xx.png"
    Style="{StaticResource KeypadImageStyle}">
    <Image.GestureRecognizers>
        <TapGestureRecognizer
            Tapped="ZeroTapped"
            NumberOfTapsRequired="1">
        </TapGestureRecognizer>
    </Image.GestureRecognizers>
</Image>

private void ZeroTapped(object sender, EventArgs e)
{
    phonenumber_label.Text = "0";
}

私有无效(对象发送方,事件参数e)
{
phonenumber_label.Text=“0”;
}


我如何在一幅图像上同时提及两个不同的点击?

我认为如果用户在150毫秒内点击两次,则可以使用计时器,这是一个双击

int Tapped=0;
private void ZeroTapped(object sender,EventArgs e)
{
    if(Tapped==0)
    {
        Device.StartTime(TimeSpan.FromMillSeconds(150),()=>
        {
            if(Tapped=1)
            {
                //1 tap.
            }
            else
            {
                 //double tap.
            }
            Tapped=0;

            return false;
        }
    }
    else
    {
        Tapped++;
    }
}

我们可以在该图像上添加两个
TapGestureRecognitor
,一个用于单点击,另一个用于双点击

xaml
我在这上面遗漏了什么?@sreejithsre很抱歉我忘记了一些代码,现在就更新它。
 <Image >
     <Image.GestureRecognizers>
         <TapGestureRecognizer Tapped="TapGestureRecognizer_Single" NumberOfTapsRequired="1"/>
         <TapGestureRecognizer Tapped="TapGestureRecognizer_Double" NumberOfTapsRequired="2"/>
     </Image.GestureRecognizers>
 </Image>
  private void TapGestureRecognizer_Single(object sender, EventArgs e)
  {
      label.Text = "0";
  }

  private void TapGestureRecognizer_Double(object sender, EventArgs e)
  {
      label.Text = "+";
  }