SfListView TapCommand for opening items, double tap on controls to change sort order

Hi,

I use an SfListView with a TapCommand binding. The users taps on a listview item to open its details.

The user should be able to change the sort order of the listview by double tapping on the controls. For instance by double tapping on a displayed name, the ListView will be sorted by Name, double tapping on city, will change the sort order to City and so on.

My xaml looks like this
<syncfusion:SfListView x:Name="listView" ItemsSource="{Binding CustList}" ItemSpacing="3" TapCommand="{Binding CustomerTappedCommand}">
     <syncfusion:SfListView.ItemTemplate>
          <DataTemplate>
               <Frame  CornerRadius="10" OutlineColor="DarkGray" BackgroundColor="LightCyan" Padding="10" HasShadow="True">
                    <StackLayout Orientation="Horizontal" BackgroundColor="{Binding LineBackground}">
                         <Label x:Name="custName" Text="{Binding Name}" FontSize="Large">
                              <Label.GestureRecognizers>
                                   <TapGestureRecognizer Command="{Binding BindingContext.SortTappedCommand,Source={x:Reference Name=listView}}" CommandParameter="Name" NumberOfTapsRequired="2"/>
                              </Label.GestureRecognizers>
                         </Label>
                    </StackLayout>
               </Frame>    
          </DataTemplate>
     </syncfusion:SfListView.ItemTemplate>
</syncfusion:SfListView>              

This does not work as expected, because by double tapping on the Label "custName", not only the sort order is changed but also the item is opened. The TapCommand of the SfListView is also fired. I tried to set flags, in the SortTappedCommand, to skip opening the item when the CustomerTappedCommand is also fired, but this does also not work stable.

I tried also with the "ItemDoubleTap" event on the SfListView (with removed GestureRecognizers on the labels), but there I didn't find a way to find out which of the labels (there are multiple Labels in my code) has been double tapped. I need this to find out on which field the user wants to sort.

Regards

Thomas


               


1 Reply

JN Jayaleshwari N Syncfusion Team November 1, 2018 12:12 PM UTC

Hi Thomas,  
  
Thanks for using Syncfusion products.  
  
We have checked the reported query from our end. We would like to let you know that the reported issue due to the framework flow.  
In android platform touch passed from parent to child so TapCommand raised before the label tap gesture. In iOS and UWP the touch is passed child to parent.  

We have a KB to handle the tap command in android platform please follow the below link.   
  
We have tried to achieve your requirement by writing the tap gesture for the parent element loaded in the ItemTemplate and for the Label. Handled the tap command in the renderer and it is working fine in the android platform. But the same is not working in the iOS and UWP due to the gesture recognizer flow.   
  
We regret to let you know that your requirement is not possible to achieve. We suggest you to load button instead of label but button tap gesture is not working in the framework so you can use command for the button.  
  
Please let us know if you require further assistance on this.  
  
Regards,  
Jayaleshwari N 


Loader.
Up arrow icon