示例#1
0
        /// <summary>
        /// Layout all children
        /// </summary>
        protected override void LayoutChildren(double x, double y, double width, double height)
        {
            MeasureHeaders(width, height);

            LayoutChild(_headerElement, new Rectangle(x, y, width, _headerSize.Request.Height));
            LayoutChild(_stickyHeaderElement, new Rectangle(x, y, width, _stickyHeaderSize.Request.Height));

            if (_relatedViews == null)
            {
                _relatedViews = new RelatedViews(this);
            }

            ScrollSource.TryGetNavigationBarProperties(_relatedViews.ContentPage, _relatedViews.NavigationPage, out double navigationBarHeight, out double navigationBarY, out bool isNavigationBarFloating, out bool isNavigationBarScrollable);

            // Update headers translationY based on previous scroll
            UpdateHeadersTranslationY(_scrollY, navigationBarHeight, navigationBarY, isNavigationBarFloating, isNavigationBarScrollable);

            bool isHeaderLayoutInScrollViewer = VisualTreeHelper.GetParent <ScrollView>(this, typeof(NavigationPage)) != null;

            if (isHeaderLayoutInScrollViewer)
            {
                double heightToAdd = 0;
                if (_relatedViews.ContentPage != null && _relatedViews.NavigationPage != null && isNavigationBarFloating == false && isNavigationBarScrollable == true)
                {
                    heightToAdd = navigationBarHeight;
                }

                LayoutChild(_contentElement, new Rectangle(x, y + _headerSize.Request.Height + _stickyHeaderSize.Request.Height + heightToAdd, width, height));
            }
            else
            {
                LayoutChild(_contentElement, new Rectangle(x, RootPage.Instance.SafeAreaInsest.Top, width, height));
            }
        }
示例#2
0
        private void OnTabViewPanChanged(object sender, PanChangedArgs args)
        {
            if (sender is CarouselView carouselView && carouselView.ItemsLayout is CarouselLayout carouselLayout)
            {
                if (_relatedViews == null)
                {
                    _relatedViews = new RelatedViews(this);
                }

                foreach (View child in carouselLayout.Children)
                {
                    ScrollView scrollView = VisualTreeHelper.FindVisualChildren <ScrollView>(child).FirstOrDefault();

                    if (scrollView != null && scrollView.ScrollY != _scrollY)
                    {
                        ScrollSource.UpdateScrollViewStart(this, _relatedViews.ContentPage, _relatedViews.NavigationPage, scrollView, _scrollY);
                    }
                }
            }
        }