[Solved] ScrollViewer ScrollToEnd Buggy

Howdy guys,

I’ve tried everything I can think of at the moment to get the ScrollViewer to reliably scroll to the end of my stack panel. I’m using it as scroll viewer for the chat portion of my game, to scroll chat messages… however it seems to be buggy. It arbitrarily attempts to scroll beyond the index. I’m only running it when the chat buffer has messages, it’s not running on any kind of game tick frequency. I like idea of using the scroll viewer for this as it will work nicely on all platforms, would love to get it more stable.

Any ideas for this or has anyone else come across this?

Ran a bunch of tests I believe the issue was related to using “ScrollToEnd” with the following:

  1. No explicitly set content (just what was inside of the scroll viewer in Game Studio)
  2. Attempting to scroll multiple ScrollViewers one after another, while some were on grid elements that were hidden.

To fix the issue I:

  1. Set to only scroll the active ScrollViewer/Stack Panel
  2. Converted to ScrollTo and use an exact vector3 position based on the #of panels.
  3. Explicity set the content for the scroll viewer, also set the stack panel owner as the scroll viewer.
  4. Enabled virtualization on all stack panels.

Not sure precisely what Item resolved the issue, looked at the source and it looked good, I think it was related to the scroll behavior emulating a user but on multiple viewers, some being on hidden grids.

Adding these tags for anyone in the future: ScrollViewer, StackPanel, Index Out of Range Exception, ScrollToEnd, ScrollTo.

1 Like