Reputation: 331
I have a scrollviewer that I want to scroll to the right when the edge is reached. I am detecting the mouse position and comparing it to the scrollviewer's ViewportWidth
. It works at first, when dragging to the edge it will scroll. However, once I let go, and try again, or if I hold on to the mouse and move back into the scrollviewer, it will keep going.
What I've noticed is that whatever width it is at initially (the first time I reach the edge), it seems to think that the ViewportWidth
is still the same, even if I have scrolled. So it will scroll no matter what once it reaches that specific width.
Is there a way I can get ViewportWidth
to update each time I scroll? I tried putting UpdateLayout
in the function after changing the offset but it did not work. The goal here is so that the width updates continually, so that I can check if the edge of the viewport has changed.
Upvotes: 0
Views: 1371
Reputation: 331
Solved my issue by combining ViewportWidth
with HorizontalOffset
. Adding them, then comparing pt.X to it gave me the exact area between the Viewport and the overflow, allowing me to scroll.
Upvotes: 1