int GetIndexFromTemplatedCell(global::Android.Views.View view) { int itemIndex = -1; if (view is ItemContentView templatedCell) { var bContext = (templatedCell?.View as VisualElement)?.BindingContext; itemIndex = ItemsViewAdapter.GetPositionForItem(bContext); } return(itemIndex); }
int GetCarouselViewCurrentIndex(int index) { var centeredView = this.GetCenteredView(); if (centeredView is ItemContentView templatedCell) { var bContext = (templatedCell?.View as VisualElement)?.BindingContext; index = ItemsViewAdapter.GetPositionForItem(bContext); } else { return(-1); } return(index); }
protected override int DetermineTargetPosition(ScrollToRequestEventArgs args) { if (args.Mode == ScrollToMode.Element) { return(ItemsViewAdapter.GetPositionForItem(args.Item)); } if (!Carousel.Loop) { return(args.Index); } if (_carouselViewLoopManager == null) { return(-1); } var carouselPosition = GetCarouselViewCurrentIndex(Carousel.Position); var getGoIndex = _carouselViewLoopManager.GetGoToIndex(this, carouselPosition, args.Index); return(getGoIndex); }