Browse Source

Invalidate measure when clearing anchor.

Steven Kirk 5 năm trước cách đây
mục cha
commit
ca7b1d75cd

+ 1 - 0
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();

+ 4 - 13
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()