void Element_OnScrollRequested(object sender, ScrollRequestedEventArgs e) { if (Element.ListLayout == HorizontalListViewLayout.Grid || Control.NumberOfItemsInSection(0) == 0 || e.Position >= Control.NumberOfItemsInSection(0)) { return; } _isInternalScroll = true; UICollectionViewScrollPosition type = UICollectionViewScrollPosition.Left; switch (e.Type) { case ScrollType.Start: type = UICollectionViewScrollPosition.Left; break; case ScrollType.End: type = UICollectionViewScrollPosition.Right; break; case ScrollType.Center: type = UICollectionViewScrollPosition.CenteredHorizontally; break; } Control.ScrollToItem( NSIndexPath.FromRowSection(e.Position, 0), type, e.Animate); }
void Element_OnScrollRequested(object sender, ScrollRequestedEventArgs e) { if (e.Position >= Control.ChildCount) { return; } var itemWidth = Control.GetChildAt(e.Position).MeasuredWidth; var width = Control.MeasuredWidth; int offset = 0; switch (e.Type) { case ScrollType.Start: offset = 0; break; case ScrollType.Center: offset = (width / 2) - (itemWidth / 2); break; case ScrollType.End: offset = width - itemWidth; break; } HorizontalLinearLayoutManager?.ScrollToPositionWithOffset(e.Position, offset); }