示例#1
0
        void EnsureLayoutInitialized()
        {
            if (_initialized)
            {
                return;
            }

            if (!ItemsView.IsVisible)
            {
                // If the CollectionView starts out invisible, we'll get a layout pass with a size of 1,1 and everything will
                // go pear-shaped. So until the first time this CollectionView is visible, we do nothing.
                return;
            }

            _initialized = true;

            ItemsViewLayout.GetPrototype = GetPrototype;

            Delegator = CreateDelegator();
            CollectionView.Delegate = Delegator;

            ItemsViewLayout.SetInitialConstraints(CollectionView.Bounds.Size);
            CollectionView.SetCollectionViewLayout(ItemsViewLayout, false);

            UpdateEmptyView();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ItemsSource = CreateItemsViewSource();
            ItemsViewLayout.GetPrototype = GetPrototype;

            Delegator = CreateDelegator();
            CollectionView.Delegate = Delegator;

            if (!Forms.IsiOS11OrNewer)
            {
                AutomaticallyAdjustsScrollViewInsets = false;
            }
            else
            {
                // We set this property to keep iOS from trying to be helpful about insetting all the
                // CollectionView content when we're in landscape mode (to avoid the notch)
                // The SetUseSafeArea Platform Specific is already taking care of this for us
                // That said, at some point it's possible folks will want a PS for controlling this behavior
                CollectionView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Never;
            }

            RegisterViewTypes();
        }
示例#3
0
        void EnsureLayoutInitialized()
        {
            if (_initialized)
            {
                return;
            }

            _initialized = true;

            ItemsViewLayout.GetPrototype = GetPrototype;

            Delegator = CreateDelegator();
            CollectionView.Delegate = Delegator;

            ItemsViewLayout.SetInitialConstraints(CollectionView.Bounds.Size);
            CollectionView.SetCollectionViewLayout(ItemsViewLayout, false);

            UpdateEmptyView();
        }
        public void UpdateLayout(ItemsViewLayout newLayout)
        {
            // Ignore calls to this method if the new layout is the same as the old one
            if (CollectionView.CollectionViewLayout == newLayout)
            {
                return;
            }

            ItemsViewLayout = newLayout;
            ItemsViewLayout.GetPrototype = GetPrototype;

            Delegator = CreateDelegator();
            CollectionView.Delegate = Delegator;

            // Make sure the new layout is sized properly
            ItemsViewLayout.ConstrainTo(CollectionView.Bounds.Size);

            CollectionView.SetCollectionViewLayout(ItemsViewLayout, false);

            // Reload the data so the currently visible cells get laid out according to the new layout
            CollectionView.ReloadData();
        }
        public void UpdateLayout(ItemsViewLayout layout)
        {
            ItemsViewLayout = layout;
            ItemsViewLayout.GetPrototype = GetPrototype;

            Delegator = CreateDelegator();

            CollectionView.Delegate = Delegator;

            if (CollectionView.CollectionViewLayout != ItemsViewLayout)
            {
                // We're updating from a previous layout

                // Make sure the new layout is sized properly
                ItemsViewLayout.ConstrainTo(CollectionView.Bounds.Size);

                CollectionView.SetCollectionViewLayout(ItemsViewLayout, false);

                // Reload the data so the currently visible cells get laid out according to the new layout
                CollectionView.ReloadData();
            }
        }