Пример #1
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Size result = finalSize;

            if (ScrollViewer is {} scrollViewer)
            {
#if SCROLLVIEWER_SUPPORTS_ANCHORING
                if (SharedHelpers.IsRS5OrHigher())
                {
                    // No-op when running on RS5 and above. ScrollViewer can do anchoring on its own.
                    scrollViewer.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
                }
                else
#endif
                {
                    var shouldApplyPendingChangeView = scrollViewer != default && HasPendingBringIntoView && !m_pendingBringIntoView.ChangeViewCalled;

                    Rect anchorElementRelativeBounds = default;
                    var  anchorElement =
                        // BringIntoView takes precedence over tracking.
                        shouldApplyPendingChangeView
                                                        ? null
                                                        :
                        // Pick the best candidate depending on HorizontalAnchorRatio and VerticalAnchorRatio.
                        // The best candidate is the element that's the closest to the edge of interest.
                        GetAnchorElement(out anchorElementRelativeBounds);

                    scrollViewer.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));

                    m_pendingViewportShift = 0.0;


                    if (shouldApplyPendingChangeView)
                    {
                        ApplyPendingChangeView(scrollViewer);
                    }
                    else if (anchorElement != default)
                    {
                        // The anchor element might have changed its position relative to us.
                        // If that's the case, we should shift the viewport to follow it as much as possible.
                        m_pendingViewportShift = TrackElement(anchorElement, anchorElementRelativeBounds, scrollViewer);
                    }
                    else if (scrollViewer != default)
                    {
                        m_pendingBringIntoView.Reset();
                    }

                    m_candidates.Clear();
                    m_isAnchorElementDirty = true;

                    _postArrange?.Invoke(this);
                }
            }

            return(result);
        }
Пример #2
0
 private void SetScrollViewerProperties(string scrollViewerName, SerialDisposable revoker)
 {
     if (SharedHelpers.IsRS5OrHigher())
     {
         if (GetTemplateChild(scrollViewerName) is ScrollViewer scrollViewer)
         {
             if (SharedHelpers.IsScrollContentPresenterSizesContentToTemplatedParentAvailable())
             {
                 scrollViewer.Loaded += OnScrollViewerLoaded;
                 revoker.Disposable   = Disposable.Create(() => scrollViewer.Loaded -= OnScrollViewerLoaded);
             }
         }
     }
 }
Пример #3
0
        void SetScrollViewerProperties(string scrollViewerName, CompositeDisposable disposable)
        {
            if (SharedHelpers.IsRS5OrHigher())
            {
                if (GetTemplateChild(scrollViewerName) is ScrollViewer scrollViewer)
                {
                    if (SharedHelpers.IsScrollContentPresenterSizesContentToTemplatedParentAvailable())
                    {
                        //	revoker = scrollViewer.Loaded(auto_revoke, { this, &OnScrollViewerLoaded });
                    }

                    if (SharedHelpers.IsScrollViewerReduceViewportForCoreInputViewOcclusionsAvailable())
                    {
                        scrollViewer.ReduceViewportForCoreInputViewOcclusions = true;
                    }
                }
            }
        }