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

ItemsRepeater inside ScrollViewer, DataContext inconsistencies #21

Open
hahagu opened this issue Sep 28, 2023 · 3 comments
Open

ItemsRepeater inside ScrollViewer, DataContext inconsistencies #21

hahagu opened this issue Sep 28, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@hahagu
Copy link

hahagu commented Sep 28, 2023

Describe the bug
Using the ItemsRepeater inside ScrollViewer causes inconsistencies with DataContext.
When I scroll to the end of the ScrollViewer, or close to, the first few items' DataContext becomes null,
and when going back up, it may get mixed around with other objects.

To Reproduce

Steps to reproduce the behavior:

  1. Have a ItemsRepeater control inside ScrollViewer and populate
  2. Populate the ItemsRepeater
  3. Scroll down the ScrollViewer far enough
  4. Monitor the DataContext of ItemsRepeater

Expected behavior

DataContext is supposed to not become null, or get jumbled around.

Screenshots

bug_case.mp4

Desktop (please complete the following information):

  • OS: Windows 11 22H2
  • Version Avalonia 11.0.4

Additional context

Bug case minimal reproducible example
bug_case.zip

@hahagu hahagu added the bug Something isn't working label Sep 28, 2023
@timunie
Copy link

timunie commented Sep 28, 2023

version means Avalonia version, not OS version. Can you please add this? thx.

@hahagu
Copy link
Author

hahagu commented Sep 28, 2023

version means Avalonia version, not OS version. Can you please add this? thx.

Hey, thanks for getting back.

I've fixed the version number.

Sorry for the confusion!

@emmauss
Copy link

emmauss commented Dec 15, 2023

ItemsRepeater uses virtualization. As you scroll items out of view, their containers will be used for items that are about to be shown, thus their Datacontext is set to the new items. The datacontext of each real item in the Source is still preserved, but its position in the Logical tree is not representative of it's visual location.

@maxkatz6 maxkatz6 transferred this issue from AvaloniaUI/Avalonia Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants