From 9cccb9f0c70bf539130f032240c6ebef9b2a3530 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 29 Sep 2023 14:20:50 +0200 Subject: [PATCH] Unregister anchor candidates on unrealize. Prevents the scroll jumping when a `TreeDataGrid` is removed and re-added to the visual tree. --- .../Primitives/TreeDataGridPresenterBase.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridPresenterBase.cs b/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridPresenterBase.cs index 2ba5c22c..9e1f45dc 100644 --- a/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridPresenterBase.cs +++ b/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridPresenterBase.cs @@ -655,6 +655,7 @@ private void RecycleElement(Control element, int index) UnrealizeElement(element); element.IsVisible = false; ElementFactory!.RecycleElement(element); + _scrollViewer?.UnregisterAnchorCandidate(element); } } @@ -663,6 +664,7 @@ private void RecycleElementOnItemRemoved(Control element) UnrealizeElementOnItemRemoved(element); element.IsVisible = false; ElementFactory!.RecycleElement(element); + _scrollViewer?.UnregisterAnchorCandidate(element); } private void TrimUnrealizedChildren()