0

I ran into kind of a dilemma with WPF's scrolling behavior in a ListBox:

  • When I set ScrollViewer.VerticalScrollBarVisibility="Auto" inside the ListBox, scrolling works fine. But clicking on the last half-visible element will move the item up to bring it into view, and the items then are aligned to the top of the topmost item, not the bottom of the lowest one. This is especially annoying when double clicking, as the item will move up under the cursor, and the second click will potentially hit the next element, thus opening the wrong one.
  • Alternatively, I could put the whole ListBox inside a ScrollViewer. This way, when clicking on the last visible item, the items are nicely aligned to the bottom of this element. But this breaks scrolling using the mouse wheel, and PageDown jumps to the last item instead of one page down.

Is there a way to have ListBox scrolling just work correctly?

1 Answer 1

1

To the point one:

Did you try to set ScrollViewer.CanContentScroll="False"?

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot, that fixed it!
New complication to the dilemma: Initialization performance is horrible with ScrollViewer.CanContentScroll="False" - for about 300 elements, it's over 5 seconds vs. 0.5 seconds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.