Double-tapping an item to select it occasionally does not work on UWP

Hi,

I am using SfListView to display items and to select an item to display a different view, I am using TapGestureRecognizer with NumberOfTapsRequired="2"

When I double tap to select an item, it occasionally doesn't work. Sometimes it requires 3 taps.


Could you please help me with a solution.





5 Replies

LN Lakshmi Natarajan Syncfusion Team January 5, 2022 01:11 PM UTC

Hi Sonal, 
 
The SfListView allows selecting items on different gestures such as tap, double tap, and hold by setting the SfListView.SelectionGesture. You can set the selection gesture as DoubleTap to achieve your requirement.  
 
Please refer to the following code snippets for more reference, 
<syncfusion:SfListView x:Name="listView"  
                        ItemSize="60" 
                        SelectionGesture="DoubleTap" 
                        ItemsSource="{Binding ContactsInfo}"> 
 
    <syncfusion:SfListView.SelectedItemTemplate> 
        <DataTemplate> 
             
        </DataTemplate> 
    </syncfusion:SfListView.SelectedItemTemplate> 
</syncfusion:SfListView> 
 
You can refer to our user guidance document regarding the same from the following link, 
 
Note: When using GestureRecognizer for the ItemTemplate, the event triggered for the first tap itself in UWP platform. We have also ensured the same behavior in Xamarin.Forms ListView. 
 
Please let us know if you need further assistance. 
 
Lakshmi Natarajan 
 



SK sonal khatri January 6, 2022 05:48 AM UTC

Hi Lakshmi,

I have made a sample application and I observed that the tap only works when we click on the item and not anywhere else.

Attaching a video for better understanding.


Thanks


Attachment: SfListView_260a4bff.zip


LN Lakshmi Natarajan Syncfusion Team January 7, 2022 12:48 PM UTC

Hi Sonal, 
 
When you add GestureRecongizers to a label, the event will be triggered when you tap on the label, but not when you tap outside of it. This is the expected behaviour. 
 
So, we suggest you add the GestureRecognizers for the StackLayout to achieve your requirement. Please refer to the following code snippets for more reference, 
<syncfusion:SfListView x:Name="listView"  
                    ItemSize="60" 
                    ItemsSource="{Binding ContactsInfo}"> 
    <syncfusion:SfListView.ItemTemplate> 
        <DataTemplate> 
            <StackLayout Orientation="Vertical"> 
                <StackLayout.GestureRecognizers> 
                    <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="2"/> 
                </StackLayout.GestureRecognizers> 
                <Label Text="{Binding ContactName}" /> 
            </StackLayout> 
        </DataTemplate> 
    </syncfusion:SfListView.ItemTemplate> 
</syncfusion:SfListView> 
 
Alternatively, you can achieve your goal by setting HorizontalOptions and VerticalOptions to FillAndExpand in order to layout the Label to the maximum size. As a result, the entire item will be the label, and the gesture will receive a touch notification. Please refer to the following documentation regarding LayoutOptions in Xamarin.Forms, 
 
 
Please refer to the following code snippets for more reference, 
<syncfusion:SfListView x:Name="listView"  
                    ItemSize="60" 
                    ItemsSource="{Binding ContactsInfo}"> 
    <syncfusion:SfListView.ItemTemplate> 
        <DataTemplate> 
            <StackLayout Orientation="Vertical"> 
                <Label Text="{Binding ContactName}" BackgroundColor="DarkGoldenrod" 
                    HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> 
                    <Label.GestureRecognizers> 
                        <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="2"/> 
                    </Label.GestureRecognizers> 
                </Label> 
            </StackLayout> 
        </DataTemplate> 
    </syncfusion:SfListView.ItemTemplate> 
</syncfusion:SfListView> 
 
Please let us know if you need further assistance. 
 
Lakshmi Natarajan 
 



SK sonal khatri January 13, 2022 03:52 AM UTC

Hi Lakshmi,


I have added two TapGestureRecognizers to a label, One gets triggered with single tap and other gets triggered on double tap.

Single tapping is working as expected, when I tap once on label or even outside of it but double tapping only works when I double tap on the label and not outside of it, it requires 3 taps for the event to get triggered when I tap outside of the label.


Could you please help me with a solution.


Thanks

Sonal






LN Lakshmi Natarajan Syncfusion Team January 13, 2022 11:30 AM UTC

Hi Sonal, 
 
We checked our simple sample based on the provided information, but we were unable to replicate the scenario on our end. And, only when you tap on the label do both single and double tap gestures get detected. 
 
We have attached the tested sample in the following link, 
 
Please check our sample and let us know if you still facing the same scenario. If not, please modify our sample based on your scenario and explain your requirement in detail which will be helpful for us to understand the requirement better and provide you the best possible solution at the earliest. 
 
Lakshmi Natarajan 
 


Loader.
Up arrow icon