diff --git a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs index fdd9076d74..cce80a2d3c 100644 --- a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs @@ -84,6 +84,7 @@ namespace ControlCatalog.Pages private void ScrollTo(int index) { + System.Diagnostics.Debug.WriteLine("Scroll to " + index); var layoutManager = ((Window)this.GetVisualRoot()).LayoutManager; var element = _repeater.GetOrCreateElement(index); layoutManager.ExecuteLayoutPass(); diff --git a/src/Avalonia.Controls/Repeater/ViewportManager.cs b/src/Avalonia.Controls/Repeater/ViewportManager.cs index fe67a1449d..b1af4f0ecc 100644 --- a/src/Avalonia.Controls/Repeater/ViewportManager.cs +++ b/src/Avalonia.Controls/Repeater/ViewportManager.cs @@ -383,19 +383,10 @@ namespace Avalonia.Controls _isBringIntoViewInProgress = false; _makeAnchorElement = null; - // Now that the item has been brought into view, we can let the anchor provider pick a new anchor. - ////foreach (var child in _owner.Children) - ////{ - //// if (!child.CanBeScrollAnchor) - //// { - //// var info = ItemsRepeater.GetVirtualizationInfo(child); - - //// if (info.IsRealized && info.IsHeldByLayout) - //// { - //// child.CanBeScrollAnchor = true; - //// } - //// } - ////} + // HACK: Invalidate measure now that the anchor has been removed so that a layout can be + // done with a proper realization rect. This is a hack not present upstream to try to fix + // https://github.com/microsoft/microsoft-ui-xaml/issues/1422 + TryInvalidateMeasure(); } public void ResetScrollers()