hello:
here is my code :
var lv = new SfListView
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
BackgroundColor = ColorHelper.LightGray,
SelectionMode = Syncfusion.ListView.XForms.SelectionMode.Single,
ItemSpacing = 1,
ItemSize = 50,
ItemTemplate = new DataTemplate(typeof(hMSG001ListViewCell)),
RightSwipeTemplate = new DataTemplate(() =>
{
var imgFavorites = new CachedImage
{
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.FillAndExpand,
BackgroundColor = ColorHelper.LightBlue,
Source = hResourcesHelper.FromResource("img_MSG_100_Favorite_White.png")
};
var imgForward = new CachedImage
{
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.FillAndExpand,
BackgroundColor = ColorHelper.Green,
Source = hResourcesHelper.FromResource("img_MSG_100_Forward_White.png")
};
{
var tap = new TapGestureRecognizer();
tap.Tapped += Favorites_Tapped;
imgFavorites.GestureRecognizers.Add(tap);
}
{
var tap = new TapGestureRecognizer();
tap.Tapped += Forward_Tapped;
imgForward.GestureRecognizers.Add(tap);
}
return new StackLayout
{
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.FillAndExpand,
Orientation = StackOrientation.Horizontal,
Padding = 0,
Spacing = 0,
Children =
{
imgFavorites,
imgForward
}
};
}),
SwipeOffset = 50,
AllowSwiping = true,
ItemsSource = listModel,
};
Content = new StackLayout {
Spacing = 0,
Children = {
lv
}
};
lv.SwipeStarted += Lv_SwipeStarted;
lv.SwipeEnded += Lv_SwipeEnded;
private void Lv_SwipeEnded(object sender, SwipeEndedEventArgs e)
{
ItemIndex = e.ItemIndex;
}
private void Lv_SwipeStarted(object sender, SwipeStartedEventArgs e)
{
ItemIndex = -1;
if (e.SwipeDirection == SwipeDirection.Right)
{
e.Cancel = true;
}
var item = (hMSG001ListViewCellBase)e.ItemData;
if (item.Channel == MSGChannelType.Hang)
{
lv.SwipeOffset = 100;
}
else
{
lv.SwipeOffset = 50;
}
}
Syncfusion.Xamarin.SfListView = 14.4.0.20
Xamarin.Forms = 2.3.3.180