示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }