From 4850571a90d3de5f09738d7978a33fea76a4c570 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 31 May 2019 22:37:07 +0200 Subject: [PATCH] Fix quick scrolling. With a bit of a hack... --- src/Avalonia.Controls/Repeaters/ViewportManager.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Avalonia.Controls/Repeaters/ViewportManager.cs b/src/Avalonia.Controls/Repeaters/ViewportManager.cs index 5986c75579..cf69f9beb6 100644 --- a/src/Avalonia.Controls/Repeaters/ViewportManager.cs +++ b/src/Avalonia.Controls/Repeaters/ViewportManager.cs @@ -188,7 +188,16 @@ namespace Avalonia.Controls.Repeaters if (!_managingViewportDisabled) { + // HACK: This is a bit of a hack. We need the effective viewport of the ItemsRepeater - + // we can get this from TransformedBounds, but this property is updated after layout has + // run, resulting in the UI being updated too late when scrolling quickly. We can + // partially remedey this by triggering also on Bounds changes, but this won't work so + // well for nested ItemsRepeaters. + // + // UWP uses the EffectiveBoundsChanged event (which I think was implemented specially + // for this case): we need to implement that in Avalonia. _effectiveViewportChangedRevoker = _owner.GetObservable(Visual.TransformedBoundsProperty) + .Merge(_owner.GetObservable(Visual.BoundsProperty).Select(_ => _owner.TransformedBounds)) .Skip(1) .Subscribe(OnEffectiveViewportChanged); }