From 5116379b537b45a7df5dc6a4a1737657b737b22b Mon Sep 17 00:00:00 2001 From: Dilip Ojha Date: Wed, 25 May 2022 16:46:16 -0700 Subject: [PATCH] disable virtualization fixes (#7142) --- dev/NavigationView/NavigationViewItem.cpp | 7 +++++++ dev/Repeater/FlowLayoutAlgorithm.cpp | 10 +++++++--- dev/Repeater/FlowLayoutAlgorithm.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dev/NavigationView/NavigationViewItem.cpp b/dev/NavigationView/NavigationViewItem.cpp index c161cb3c17..039690616b 100644 --- a/dev/NavigationView/NavigationViewItem.cpp +++ b/dev/NavigationView/NavigationViewItem.cpp @@ -7,6 +7,7 @@ #include "NavigationView.h" #include "NavigationViewItem.h" #include "NavigationViewItemAutomationPeer.h" +#include "StackLayout.h" #include "Utils.h" static constexpr wstring_view c_navigationViewItemPresenterName = L"NavigationViewItemPresenter"sv; @@ -156,6 +157,12 @@ void NavigationViewItem::LoadMenuItemsHost() { m_repeater.set(repeater); + if (auto stackLayout = repeater.Layout().try_as()) + { + auto stackLayoutImpl = winrt::get_self(stackLayout); + stackLayoutImpl->DisableVirtualization(true); + } + // Primary element setup happens in NavigationView m_repeaterElementPreparedRevoker = repeater.ElementPrepared(winrt::auto_revoke, { nvImpl, &NavigationView::OnRepeaterElementPrepared }); m_repeaterElementClearingRevoker = repeater.ElementClearing(winrt::auto_revoke, { nvImpl, &NavigationView::OnRepeaterElementClearing }); diff --git a/dev/Repeater/FlowLayoutAlgorithm.cpp b/dev/Repeater/FlowLayoutAlgorithm.cpp index 8af0e7d777..733cc2c891 100644 --- a/dev/Repeater/FlowLayoutAlgorithm.cpp +++ b/dev/Repeater/FlowLayoutAlgorithm.cpp @@ -58,9 +58,12 @@ winrt::Size FlowLayoutAlgorithm::Measure( } } - m_elementManager.OnBeginMeasure(orientation); + if(!disableVirtualization) + { + m_elementManager.OnBeginMeasure(orientation); + } - const int anchorIndex = GetAnchorIndex(availableSize, isWrapping, minItemSpacing, layoutId); + const int anchorIndex = GetAnchorIndex(availableSize, isWrapping, minItemSpacing, disableVirtualization, layoutId); Generate(GenerateDirection::Forward, anchorIndex, availableSize, minItemSpacing, lineSpacing, maxItemsPerLine, disableVirtualization, layoutId); Generate(GenerateDirection::Backward, anchorIndex, availableSize, minItemSpacing, lineSpacing, maxItemsPerLine, disableVirtualization, layoutId); if (isWrapping && IsReflowRequired()) @@ -147,13 +150,14 @@ int FlowLayoutAlgorithm::GetAnchorIndex( const winrt::Size& availableSize, bool isWrapping, double minItemSpacing, + const bool disableVirtualization, const wstring_view& layoutId) { int anchorIndex = -1; winrt::Point anchorPosition{}; auto context = m_context.get(); - if (!IsVirtualizingContext()) + if (!IsVirtualizingContext() || disableVirtualization) { // Non virtualizing host, start generating from the element 0 anchorIndex = context.ItemCountCore() > 0 ? 0 : -1; diff --git a/dev/Repeater/FlowLayoutAlgorithm.h b/dev/Repeater/FlowLayoutAlgorithm.h index 87be9c89ac..0d0ea3162f 100644 --- a/dev/Repeater/FlowLayoutAlgorithm.h +++ b/dev/Repeater/FlowLayoutAlgorithm.h @@ -77,6 +77,7 @@ class FlowLayoutAlgorithm : OrientationBasedMeasures const winrt::Size& availableSize, bool isWrapping, double minItemSpacing, + const bool disableVirtualization, const wstring_view& layoutId); void Generate( GenerateDirection direction,