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); }
private void ScrollToCurrentItem() { if (Control == null || Element.CurrentIndex == -1 || Element.CurrentIndex >= Control.NumberOfItemsInSection(0) || Control.NumberOfItemsInSection(0) == 0) { return; } InternalLogger.Info($"ScrollToCurrentItem( Element.CurrentIndex = {Element.CurrentIndex} )"); _isInternalScroll = true; Control.LayoutIfNeeded(); UICollectionViewScrollPosition position = UICollectionViewScrollPosition.Top; if (Element.ListLayout == HorizontalListViewLayout.Linear) { switch (Element.SnapStyle) { case SnapStyle.Center: position = UICollectionViewScrollPosition.CenteredHorizontally; break; case SnapStyle.Start: position = UICollectionViewScrollPosition.Left; break; } } Control.ScrollToItem( NSIndexPath.FromRowSection(Element.CurrentIndex, 0), position, false); }
/// <summary> /// Programatically select asset. /// </summary> /// <param name="index">Index.</param> /// <param name="animated">If set to <c>true</c> animated.</param> /// <param name="scrollPosition">Scroll position.</param> public void SelectAsset(int index, bool animated, UICollectionViewScrollPosition scrollPosition) { var path = NSIndexPath.FromItemSection(index, LayoutConfiguration.SectionIndexForAssets); CollectionView.SelectItem(path, animated, scrollPosition); }
public virtual void ScrollToItemAtIndexPath(NSIndexPath indexPath, UICollectionViewScrollPosition atScrollPosition, bool animated) { }
public virtual void SelectItemAtIndexPath([Optional] NSIndexPath indexPath, bool animated, UICollectionViewScrollPosition scrollPosition) { }
public void ScrollToItem(NSIndexPath indexPath, UICollectionViewScrollPosition scrollPosition, bool animated) => collectionView.ScrollToItem(indexPath, scrollPosition, animated);