Closed IZIDIA closed 4 hours ago
By the way. Removing the InitializeElements(false /*recycleRows*/);
line completely solves the scrolling problem. When you switch to another tab and back. Your scrolling position remains in the same place. I plan to spend some more time solving this problem.
See #15218
This should solve both problems. https://github.com/AvaloniaUI/Avalonia/pull/16140
Describe the bug
Hello. I'm using a DataGrid in my project and have noticed a performance hit when my table is attached to a visual tree. I ran a dotTrace measurement inside the Rider IDE and noticed that the
InitializeElements
method was taking a long time.The commit that was made earlier solves one of the problems: https://github.com/AvaloniaUI/Avalonia/issues/9527
pull: https://github.com/almightyju/Avalonia/commit/e9f2cb34789017b0db57e33d02660c2bc70af4bf
But I believe there is a bug in this commit.
InitializeElements(bool recycleRows)
now we usefalse
.This leads to the fact that every time we connect to the visual tree, we build the columns in the table all over again. But at the same time, we only need to update the rows. We need use only
RefreshRows
inside methodInitializeElements(bool recycleRows)
.And so we must replace this:
TO:
My measurements using Stopwatch (I was just switching between tabs):
InitializeElements(false /*recycleRows*/);
InitializeElements(true /*recycleRows*/);
To Reproduce
Open the ready-made DataGrid examples in the avalonia project and start switching between tabs.
Expected behavior
No response
Avalonia version
11.1-rc1
OS
Windows
Additional context
No response