void UpdateCurrentPage(bool animated = true)
        {
            ContentPage current = Carousel.CurrentPage;

            if (current != null)
            {
                int index = Carousel.CurrentPage != null?CarouselPage.GetIndex(Carousel.CurrentPage) : 0;

                if (index < 0)
                {
                    index = 0;
                }

                if (SelectedIndex == index)
                {
                    return;
                }

                if (animated)
                {
                    NSAnimationContext.RunAnimation(context => { ((NSPageController)Animator).SelectedIndex = index; },
                                                    CompleteTransition);
                }
                else
                {
                    SelectedIndex = index;
                }
            }
        }
        void UpdateCurrentPage(bool animated = true)
        {
            ContentPage current = Carousel.CurrentPage;

            if (current != null)
            {
                ScrollToPage(CarouselPage.GetIndex(current), animated);
            }
        }
        public void UpdateCurrentItem()
        {
            if (_page.CurrentPage == null)
            {
                throw new InvalidOperationException("CarouselPage has no children.");
            }

            int index = CarouselPage.GetIndex(_page.CurrentPage);

            if (index >= 0 && index < _page.Children.Count)
            {
                _pager.CurrentItem = index;
            }
        }
        void OnPagesChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            _ignoreNativeScrolling = true;

            NotifyCollectionChangedAction action = e.Apply((o, i, c) => InsertPage((ContentPage)o, i), (o, i) => RemovePage((ContentPage)o, i), Reset);

            PositionChildren();

            _ignoreNativeScrolling = false;

            if (action == NotifyCollectionChangedAction.Reset)
            {
                int index = Carousel.CurrentPage != null?CarouselPage.GetIndex(Carousel.CurrentPage) : 0;

                if (index < 0)
                {
                    index = 0;
                }

                ScrollToPage(index);
            }
        }
Exemple #5
0
 protected override int GetIndex(ContentPage page)
 {
     return(CarouselPage.GetIndex(page));
 }