Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix horizontal ScrollToView in VirtualizingStackPanel in some cases #14419

Merged

Conversation

BAndysc
Copy link
Contributor

@BAndysc BAndysc commented Jan 31, 2024

What does the pull request do?

This fixes a case when elements in VirtualizingStackPanel have different widths, ScrollToView is invoked with an element whose TargetRect in BringIntoView is out of bounds.

I am not sure if this is a big hack fix or an alright solution.

What is the current behavior?

In the BringToView ScrollViewer extents are still not updated and even thought the Offset is being set to the correct position, it is clamped to the old extents thus ScrollToView doesn't scroll to the element, see the video below:

Screen.Recording.2024-01-31.at.01.28.02.mov

What is the updated/expected behavior with this PR?

When calling BringIntoView again, the Y offset should be correct and ScrollViewer's extents should be correct, thus this call should scroll to the right horizontal position.

Checklist

  • Added unit tests (if possible)?
  • Added XML documentation to any related classes?

Breaking changes

n/a

Obsoletions / Deprecations

n/a

Fixed issues

Fixes #14418

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0044191-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@timunie
Copy link
Contributor

timunie commented Jan 31, 2024

I wonder if that also solves other virtualization scrolling issues, namely if items have different sizes.

@BAndysc
Copy link
Contributor Author

BAndysc commented Jan 31, 2024

I wonder if that also solves other virtualization scrolling issues, namely if items have different sizes.

Probably not, as far as I understand other virtualization scrolling issues mostly come from incorrectly estimating items height, in result scroll offset is not correctly set. In my case, Y offset was correctly set (items have same heights), but X offset wasn't because Extent was not updated yet during first BringIntoView. This is kinda a chicken-and-egg problem - in order to update width extent, the scroll offset Y needs to be set.

@maxkatz6 maxkatz6 requested a review from grokys January 31, 2024 22:47
This fixes a case when elements have different widths and the BringIntoView wants to scroll horizontally due to custom TargetRect
@BAndysc BAndysc force-pushed the virtualizingtreeview-bringtoview branch from 62f6584 to 078d7e4 Compare February 1, 2024 15:15
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0044295-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added the backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch label Feb 6, 2024
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0044473-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Feb 6, 2024
Merged via the queue into AvaloniaUI:master with commit e0127c6 Feb 6, 2024
6 checks passed
maxkatz6 added a commit that referenced this pull request Feb 8, 2024
This fixes a case when elements have different widths and the BringIntoView wants to scroll horizontally due to custom TargetRect

Co-authored-by: Max Katz <maxkatz6@outlook.com>
@maxkatz6 maxkatz6 added backported-11.0.x and removed backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch labels Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ListBox with VirtualizedStackPanel doesn't scroll correctly horizontally
4 participants