Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Disable second tap on Label

$
0
0

Hi All,

I have a label where i am handling the click event using guestures. code below.

XAML CODE

        <Label Text="Click Here" FontSize="Micro">
            <Label.GestureRecognizers>
                <TapGestureRecognizer Tapped="OnTap"></TapGestureRecognizer>
            </Label.GestureRecognizers>
        </Label>

CODE

                    private void OnTap(object sender, EventArgs e)
                            {
                                Navigation.PushModalAsync(new Notice());
                            }

This works. But if user clicks on the label multiple times, then the tap event is called multiple times. I want it to be called only once.

How do i fix this?

I have tried the below solution.

                    private async void OnTap(object sender, EventArgs e)
                            {
                                if (userTapped)
                                    return;
                                userTapped = true;
                                await Navigation.PushModalAsync(new Notice());
                                userTapped = false;
                            }

This works sometimes and sometimes it doesn't. My assumption is that the Notice ( Content Page) is taking too much time.

Thank you.

Regards,
Manoj


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>