How to autoscroll ScrollViewer to bottom? #12931
Replies: 9 comments 6 replies
-
You may need to track the current offset somewhere and if the scrollviewer is at the buttom currently (before adding a new item). I don't see a different option. Avalonia.Behaviors may be helpful in this case to track it. |
Beta Was this translation helpful? Give feedback.
-
The problem is for example when the ListBox area is reduced (window resized), even if the scroll is at the bottom then the offset will shrink, thus the scroll is not at the bottom anymore. I am checking in ListBox.LayoutUpdated if the Extent.Height has changed, trying to detect this case, but sometimes Offset.Y has shrunk while the Extent.Height is unchanged. So it looks like the offset is reduced while ListBox size stays the same. It would be much better if the scroll would stay at bottom when ListBox height is changed (by resizing window). |
Beta Was this translation helpful? Give feedback.
-
I will try that, thanks |
Beta Was this translation helpful? Give feedback.
-
It would be more logical if offset is at maximum then it should stay that after resize. I thought maybe this could be improved in how Avalonia recalculates the offset. |
Beta Was this translation helpful? Give feedback.
-
When scroll is at top it will stay at the top when the ListBox is resized. However this does not apply if the scroll is at the bottom. |
Beta Was this translation helpful? Give feedback.
-
Keep in mind, that content should be fully loaded before scrolling. As before it doesn't have any height yet. |
Beta Was this translation helpful? Give feedback.
-
It is fully loaded, and bigger than the ListBox. I scroll to the bottom, resize the ListBox(make it smaller and larger, repeating) and the scroll will automatically move from the bottom. If you like I could upload a project demonstrating this. |
Beta Was this translation helpful? Give feedback.
-
Small correction, if I reduce the size of the ListBox, the scroll will come off the bottom. Which seems is in contrast to the behavior when the scroll is at the top. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I am implementing a chat (ListBox) which should be auto-scrolled to bottom unless if the user has manually scrolled up.
How to detect that user manually scrolled up?
Beta Was this translation helpful? Give feedback.
All reactions