public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();
            if (isViewAppearing || isViewRotating)
            {
                // Force the UICollectionViewFlowLayout to get laid out again with the new size if
                // a) The view is appearing.  This ensures that
                //    collectionView:layout:sizeForItemAtIndexPath: is called for a second time
                //    when the view is shown and when the view *frame(s)* are actually set
                //    (we need the view frame's to have been set to work out the size's and on the
                //    first call to collectionView:layout:sizeForItemAtIndexPath: the view frame(s)
                //    aren't set correctly)
                // b) The view is rotating.  This ensures that
                //    collectionView:layout:sizeForItemAtIndexPath: is called again and can use the views
                //    *new* frame so that the buttonBarView cell's actually get resized correctly
                CachedCellWidths = CalculateWidths();
                ButtonBarView.CollectionViewLayout.InvalidateLayout();

                // When the view first appears or is rotated we also need to ensure that the barButtonView's
                // selectedBar is resized and its contentOffset/scroll is set correctly (the selected
                // tab/cell may end up either skewed or off screen after a rotation otherwise)
                ButtonBarView.MoveToIndex((int)CurrentIndex, animated: false, swipeDirection: SwipeDirection.None, pagerScroll: PagerScroll.ScrollOnlyIfOutOfScreen);
                ButtonBarView.SelectItem(NSIndexPath.FromRowSection((System.nint)CurrentIndex, 0), false, UICollectionViewScrollPosition.None);
            }
        }
 public override void ReloadPagerTabStripView()
 {
     base.ReloadPagerTabStripView();
     if (IsViewLoaded)
     {
         ButtonBarView.ReloadData();
         cachedCellWidths = CalculateWidths();
         ButtonBarView.MoveToIndex((int)CurrentIndex, animated: false, swipeDirection: SwipeDirection.None, pagerScroll: PagerScroll.Yes);
     }
 }
 public void PagerTabStripViewController(PagerTabStripViewController pagerTabStripViewController, int fromIndex, int toIndex)
 {
     if (shouldUpdateButtonBarView)
     {
         ButtonBarView.MoveToIndex(toIndex, animated: true, swipeDirection: toIndex < fromIndex ? SwipeDirection.Right : SwipeDirection.Left, pagerScroll: PagerScroll.Yes);
         if (ChangeCurrentIndex != null)
         {
             var oldCell = ButtonBarView.CellForItem(NSIndexPath.FromItemSection(new nint(CurrentIndex != fromIndex ? fromIndex : toIndex), 0)) as ButtonBarViewCell;
             var newCell = ButtonBarView.CellForItem(NSIndexPath.FromItemSection(new nint(CurrentIndex), 0)) as ButtonBarViewCell;
             ChangeCurrentIndex(oldCell, newCell, true);
         }
     }
 }
        public void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath)
        {
            if (indexPath.Item != CurrentIndex)
            {
                ButtonBarView.MoveToIndex((int)indexPath.Item, true, SwipeDirection.None, PagerScroll.Yes);
                shouldUpdateButtonBarView = false;

                var oldCell = ButtonBarView.CellForItem(NSIndexPath.FromItemSection(new nint(CurrentIndex), 0)) as ButtonBarViewCell;
                var newCell = ButtonBarView.CellForItem(NSIndexPath.FromItemSection(indexPath.Item, 0)) as ButtonBarViewCell;

                if (PagerBehaviour.IsProgressiveIndicator)
                {
                    ChangeCurrentIndexProgressive?.Invoke(oldCell, newCell, 1, true, true);
                }
                else
                {
                    ChangeCurrentIndex?.Invoke(oldCell, newCell, true);
                }
                MoveToViewControllerAtIndex((uint)indexPath.Item);
            }
        }