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

The listbox scrollbar behaves abnormally #17349

Open
NeverMorewd opened this issue Oct 24, 2024 · 8 comments
Open

The listbox scrollbar behaves abnormally #17349

NeverMorewd opened this issue Oct 24, 2024 · 8 comments
Labels

Comments

@NeverMorewd
Copy link
Contributor

Describe the bug

After adding several items to ListBox, scroll the listbox with draging ScrollBar or code: listbox.AutoScrollToSelectedItem = true;listbox.SelectedItem = item will raise an abnormal display.

image

To Reproduce

clone: https://github.com/NeverMorewd/Lemon.ModuleNavigation
start: Lemon.ModuleNavigation.Sample.DesktopHosting
Click ModuleB and ModuleC alternately to add enough items to ListBox for showing ScrollBar
Drag ScrollBar slowly up and down will produce this issue

20241024223412_rec_

Expected behavior

No response

Avalonia version

11.1.3

OS

Windows

Additional context

No response

@timunie
Copy link
Contributor

timunie commented Oct 24, 2024

Can you please provide a minimum sample to reproduce? We have no capacity to debug into a more complex sample.

@NeverMorewd
Copy link
Contributor Author

Can you please provide a minimum sample to reproduce? We have no capacity to debug into a more complex sample.

up to now, I have not reproduced with a mini project
And I found two old issues which seems to be related with this issue.
#10585
#10367

In addition
If i commented out this line, the listboxitem overlap issue will not produce.
image

NeverMorewd added a commit to NeverMorewd/Lemon.ModuleNavigation that referenced this issue Oct 25, 2024
NeverMorewd added a commit to NeverMorewd/Lemon.ModuleNavigation that referenced this issue Oct 25, 2024
@NeverMorewd
Copy link
Contributor Author

NeverMorewd commented Oct 25, 2024

The overlapping ListBoxItem issue can now be avoided using ScrollToView, but the scrollbar's abnormal behavior still persists. When I hover over the scrollbar, hold down the left mouse button and drag up/down, the mouse pointer gradually drifts away from the scrollbar. The longer you drag, the further the mouse gets from the scrollbar, until it completely leaves the scrollbar's interactive area, making it impossible to continue dragging.

@NeverMorewd
Copy link
Contributor Author

After disabling virtualization of the ListBox, both the overlapping issue and scrollbar behavior problem no longer occur. It appears these issues were caused by virtualization.

<ListBox.ItemsPanel>
<ItemsPanelTemplate>
	<StackPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>

@timunie
Copy link
Contributor

timunie commented Oct 25, 2024

Yeah virtualization with different item sizes is a pain and will always be. If you have a handful of items and can deal without, that's great

@NeverMorewd
Copy link
Contributor Author

Yeah virtualization with different item sizes is a pain and will always be. If you have a handful of items and can deal without, that's great

Do we have a plan to solve the virtualization problem? Also I noticed that the issue mentioned in the other issue, although it has been closed, I used the code at the time and upgraded to 11.1.4 ,the virtualization problem still persists.

@timunie
Copy link
Contributor

timunie commented Oct 28, 2024

@NeverMorewd can you please try to use Dispather.UiThread.Post(() => { selecting.SelectedItem = whatever; }) in order to give the control enough time to load?

@timunie
Copy link
Contributor

timunie commented Oct 28, 2024

Reproduction.zip

@grokys fyi attached is a minimal sample of the other linked issue, updated to 11.2.0-rc2.

Issue is only visible if you:

  1. expand a random item
  2. Select this item
  3. Scroll upwards a little bit
  4. Notice the selected item is there as a ghost item

@NeverMorewd Timeframe to solve? --> No priority from our side currently unless it becomes a customer issue. If you are a paying customer, let me know. If you want to digg into Avalonia source and file a PR, that is also an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants