TapGestureRecognizer not working properly in single click for StackLayout and Grid.

cherantcherant USMember ✭✭

Hi All,

I have used TapGestureRecognizer for stacklayout and grid in my code and when click it works properly in other device except Samsung S6 galaxy. While double click it works fine.

Code Snippet:


<StackLayout.GestureRecognizers>

</StackLayout.GestureRecognizers>

Am using Xamarin Forms- 2.4.0.282 version. Could you please help me to resolve this?

Regards,

Cheran

Posts

  • VenkataSwamyVenkataSwamy INMember ✭✭✭
    edited November 2017

    Hi @cherant,

    Put different BackgroundColor for StackLayout and Grid then check how much space occupying and you can see Tapping area also.

    Check your code once again with below code

           <StackLayout 
                 VerticalOptions="StartAndExpand" 
                 HorizontalOptions="StartAndExpand">
                <StackLayout.GestureRecognizers>
                <TapGestureRecognizer 
                   Tapped="OnButtonTapped" 
                   NumberOfTapsRequired="1">
               </StackLayout.GestureRecognizers>
           </StackLayout>
    

    And if it is nested StackLayout or grid

  • SreeeeSreeee INMember ✭✭✭✭

    Hi @seanyda and @VenkataSwamy I also have the same problem, but in my case problem is only with the UWP, in Android and IOS it is working fine.

    I have an entry surrounded by stacklayout and for the stack I added GestureRecognizers like below:

             <StackLayout>
                    <Entry
                        TextColor="Black"
                        x:Name="phoneone"/>
                        <StackLayout.GestureRecognizers>
                            <TapGestureRecognizer
                                    Tapped="CallingPhone1"
                                    NumberOfTapsRequired="1">
                            </TapGestureRecognizer>
                        </StackLayout.GestureRecognizers> 
                </StackLayout>
    

    My CallingPhone1 code:

     public async void CallingPhone1(object sender,EventArgs args)
             {
                    Debug.WriteLine("Enter1");
                    var answer = await DisplayAlert("Alert", "Do you want to call this number?", "Yes", "No");
                    if (answer)
                    {
                        string firstphone = phoneone.Text;
                        try
                        {
                            PhoneDialer.Open(firstphone);
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine("Exception:>>" + ex);
                        }
                    }
                }
    

    When I Tap on the Entry, noting is happening in UWP. But showing The thread 0x6adc has exited with code 0 (0x0) in output box. I am using xamarin.forms 2.5.0.121934

    Thanks in advance :smile:

  • NickKovalskyNickKovalsky USMember ✭✭✭

    For my part the problem with not firing randomly was due to omitting NumberOfTapsRequired="1"

Sign In or Register to comment.