From 402e497fa8a007714423fcbbdccc4efac8fd3b09 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 3 Jun 2020 15:59:01 +0200 Subject: [PATCH] Register action on lower priority than render. `OnEffectiveViewportChanged` needs to be triggered first, otherwise `_makeAnchorElement` is cleared too early, breaking scrolling in a list with variable-height items. --- src/Avalonia.Controls/Repeater/ViewportManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Repeater/ViewportManager.cs b/src/Avalonia.Controls/Repeater/ViewportManager.cs index 3ba117d4e7..e2848c5aa1 100644 --- a/src/Avalonia.Controls/Repeater/ViewportManager.cs +++ b/src/Avalonia.Controls/Repeater/ViewportManager.cs @@ -346,10 +346,14 @@ namespace Avalonia.Controls } // Register action to go back to how things were before where any child can be the anchor. + // Register action to go back to how things were before where any child can be the anchor. Here, + // WinUI uses CompositionTarget.Rendering but we don't currently have that, so post an action to + // run *after* rendering has completed (priority needs to be lower than Render as Transformed + // bounds must have been set in order for OnEffectiveViewportChanged to trigger). if (!_isBringIntoViewInProgress) { _isBringIntoViewInProgress = true; - Dispatcher.UIThread.Post(OnCompositionTargetRendering); + Dispatcher.UIThread.Post(OnCompositionTargetRendering, DispatcherPriority.Loaded); } } }