- Home
- Forum
- Xamarin.Forms
- How to exclude a button like zone in a SfListView from the select action.
How to exclude a button like zone in a SfListView from the select action.
As provided in the samples I have a SfListView.
The listview allows drag&drop. Also I have a button like zone (Grid) on the left side.
If I tap on the button a command is executed to select or deselect the item.
I also have a drag indicator.
The Grid has a TapGestureRecognizer to achive the button select and deselect commands.
Now I want that the item select actions are not called when I tap into the button zone.
So tapping on the button zone, just selects or deselects the button.
But tapping on the label area should call the normal selection changing/changed events.
Here an excerpt of my xaml code.
<syncfusion:SfListView x:Name="listView" DragStartMode="OnHold,OnDragIndicator" ItemDragging="OnItemDragging" ItemSize="40" SelectionChanged="OnSelectionChanged" SelectionChanging="OnSelectionChanging" SelectionMode="Single"> <syncfusion:SfListView.Behaviors> <local:FormsSelectorBehavior /> </syncfusion:SfListView.Behaviors> <syncfusion:SfListView.ItemTemplate> <DataTemplate> <Frame Padding="0" HasShadow="True"> <Frame.InputTransparent> <OnPlatform x:TypeArguments="x:Boolean" Android="True" WinPhone="False" iOS="False" /> </Frame.InputTransparent> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="60" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="60" /> </Grid.ColumnDefinitions> <Grid Padding="20,10,20,10"> <Grid.GestureRecognizers> <TapGestureRecognizer Command="{Binding Path=BindingContext.SelectCommand, Source={x:Reference Name=listView}}" CommandParameter="{Binding .}" /> </Grid.GestureRecognizers> <Image Aspect="AspectFill" HorizontalOptions="Center" IsVisible="{Binding IsSelected}" Source="checked.png" VerticalOptions="Center" /> <Image Aspect="AspectFill" HorizontalOptions="Center" IsVisible="{Binding IsSelected, Converter={StaticResource inverseBoolConverter}}" Source="unchecked.png" VerticalOptions="Center" /> </Grid> <Label x:Name="textLabel" Grid.Column="1" Margin="5,0,0,0" FontSize="15" HorizontalOptions="Start" Text="{Binding Name}" TextColor="{Binding ItemColor}" VerticalOptions="Center" />
SIGN IN To post a reply.
2 Replies
MR
MRi
June 27, 2018 12:09 PM UTC
I solved it in adding just another TapGestureRecognizer for the label.
Now I don't use the selected items features any longer.
But I am still interested if it is possible to solve it without a second gesture recognizer.
I also found out, that the TapGestureRecognizer are executed after the OnSelectionChanging/OnSelectionChanged events are fired. I just tried to use flags. But this would only work, if the sequence would be
Changing Event
Tap Gesture command
Changed Events...
RS
Rawoof Sharief Muthuja Sherif
Syncfusion Team
June 28, 2018 01:10 PM UTC
Hi Martin,
Thanks for contacting Syncfusion support.
We have checked the reported query from our end. We would like to let you know that we have already published KB for your requirement and you can refer the below KB link for further details.
If the above kb does not meet your requirement could you please share the xaml page or simple sample to reproduce the reported issue.
Please let us know if you require further assistance.
Regards,
Rawoof M.
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
MR MRi
- Jun 27, 2018 08:53 AM UTC
- Jun 28, 2018 01:10 PM UTC