Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the difference between ScrollViewer.ScrollToEnd() and ScrollViewer.ScrollToBottom()?

Does anyone know what is the difference between ScrollViewer.ScrollToEnd() and ScrollViewer.ScrollToBottom()?

In Visual Studio 2022, the description of ScrollToEnd() and ScrollToBottom() is the same:
"Scrolls vertically to the end of ScrollViewer content."

Nevertheless, there must be a difference, otherwise there would not exist both.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks for your answers!

>Solution :

ScrollToBottom() scrolls to the bottommost Y coordinate, but does not change the horizontal offset. Thus this method only changes the current Y offset.

ScrollToEnd() scrolls to both the bottommost Y coordinate AND the rightmost X coordinate. Thus this method changes both the current Y AND the current X coordinates.

Note that in many cases like this, if you’re unsure what the code does you can look at the implementation on https://source.dot.net/

For this particular case: https://source.dot.net/#PresentationFramework/System/Windows/Controls/ScrollViewer.cs,488ab4a977a015eb

However, the documentation does actually specify the behaviour for these methods:

https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.scrollviewer.scrolltoend?view=windowsdesktop-6.0

The naming of those two methods is not great. It might have been better to call them ScrollToBottom() and ScrollToBottomRight() and then it would have been more obvious (IMO).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading