<syncfusion:SfListView
x:Name="collectionView"
AllowSwiping="True"
AutoFitMode="Height"
BackgroundColor="{StaticResource Gray-100}"
ItemsSource="{Binding ContrastCollection}">
<syncfusion:SfListView.RightSwipeTemplate>
<DataTemplate>
<Grid ColumnSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
Grid.ColumnDefinitions>
<Label
Grid.Column="0"
BackgroundColor="{StaticResource PrimaryButton}"
FontFamily="FontIcons"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="{StaticResource Edit}"
TextColor="White"
VerticalOptions="Fill"
VerticalTextAlignment="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference collectionView}, Path=BindingContext.EditItemCommand}" />
Label.GestureRecognizers>
Label>
<Label
Grid.Column="1"
BackgroundColor="{StaticResource SecondaryButton}"
FontFamily="FontIcons"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="{StaticResource Delete}"
TextColor="White"
VerticalOptions="Fill"
VerticalTextAlignment="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference collectionView}, Path=BindingContext.EditItemCommand}" />
Label.GestureRecognizers>
Label>
Grid>
DataTemplate>
syncfusion:SfListView.RightSwipeTemplate>
<syncfusion:SfListView.ItemTemplate>
<DataTemplate>
<StackLayout Spacing="0">
<Label
Padding="12"
FontFamily="Font-Medium"
FontSize="Small"
Text="{Binding Data}" />
<BoxView
BackgroundColor="{StaticResource Gray-300}"
HeightRequest="1" />
StackLayout>
DataTemplate>
syncfusion:SfListView.ItemTemplate>
syncfusion:SfListView>
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="EditButton_Tapped"/>
Label.GestureRecognizers>
Query |
Response | |
(1) How can I make the width of each swipe area/label wider? I have tried placing it in grids etc, but the width seems to be fixed. Setting WidthRequest etc does not seem to work. |
We would like to inform you that you can set the swipe view size by using the SfListView.SwipeOffset property.
Please refer to our user guidance document regarding the same,
| |
(2) In the Tapped Event in the TapGestureRecognizer for the Button, how can I get the details of the record that is currently been selected in the Tapped Event?
The ItemsSource Model has an Id Field and a Data Field. So ideally in the EditButton_Tapped event, I would need this model for the currently selected item - essentially 'ItemData' but unsure how to get this.
|
We would like to inform you that you can get the swiped item details from the CommandParameter. Please refer to the following code snippets for more reference,
|
I had follow this way ,but still no luck ...any other way
i just wanna swipe the item and delete it....i using debug and it say my list view is null...i need select n swipe then only can delete
in xaml i already using command parameter , {binding .}
hello
Thank you for this answer on his problem!
May you please provide me an complete example of this method above
"TapGestureRecognizer_Tapped", I'm currently using a Text Label instead of an Delete Image Icon and also get problem at this step.
Thanks!
Hi hoang Gia,
We have attached the sample to obtain the details of a swiped item. Please take a look at the code snippet below for further information.
Code Snippet
private void TapGestureRecognizer_Tapped(object sender, EventArgs e) { var tappedItem = (e as TappedEventArgs).Parameter as ListViewInboxInfo; var inboxInfo= (listView.BindingContext as ListViewSwipingViewModel).InboxInfo; inboxInfo.Remove(tappedItem); } |
Regards,
Riyas Hameed M