Skip to content

Commit

Permalink
disable virtualization fixes (#7142)
Browse files Browse the repository at this point in the history
  • Loading branch information
ojhad authored May 25, 2022
1 parent de1e768 commit 5116379
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions dev/NavigationView/NavigationViewItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -156,6 +157,12 @@ void NavigationViewItem::LoadMenuItemsHost()
{
m_repeater.set(repeater);

if (auto stackLayout = repeater.Layout().try_as<winrt::StackLayout>())
{
auto stackLayoutImpl = winrt::get_self<StackLayout>(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 });
Expand Down
10 changes: 7 additions & 3 deletions dev/Repeater/FlowLayoutAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions dev/Repeater/FlowLayoutAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5116379

Please sign in to comment.