Hello,
Welcome to our Microsoft Q&A platform!
You can use TimeSpan
to achieve this.
You can refer to the following the code:
MainPage.xaml
<StackLayout>
<Label Text="" x:Name="phonenumber_label"/>
<Image
Grid.Column="1"
Source="test.png">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="ZeroTapped"
>
</TapGestureRecognizer>
</Image.GestureRecognizers>
</Image>
</StackLayout>
MainPage.xaml.cs
public partial class MainPage : ContentPage
{
int TouchCount;
public MainPage()
{
InitializeComponent();
}
private void ZeroTapped(object sender, EventArgs e)
{
if (TouchCount < 1)
{
TimeSpan tt = new TimeSpan(0, 0, 1);
Device.StartTimer(tt, TestHandleFunc);
}
TouchCount++;
}
bool TestHandleFunc()
{
if (TouchCount > 1)
{
//Your action for Double Click here
DisplayAlert("", "Two Clicks", "OK");
}
else
{
//Your action for Single Click here
DisplayAlert("", "One Click", "OK");
}
TouchCount = 0;
return false;
}
}
Best Regards,
Jessie Zhang
---
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.