The events scrolltoVerticalOffset or the scrolltoHorizontalOffset do not change the values of the scrollviewer.
Please tell me at which event does the values HorizontalOffset and the VerticalOffset get changed?
I have tried LayoutUpdated() method but it goes in a infinite loop.
Thanks in advance
In general the values of
HorizontalOffsetandVerticalOffsetare not updated except during theLayoutUpdatedevent after theScrollContentPresenter(or otherIScrollInfo) has updated its value and called InvalidateScrollInfo(). The one exception is that the DependencyProperty for each of these is updated during deferred scrolling (but surprisingly the corresponding CLR property is not updated), but this probably does not apply in your case.There are no
ScrollToHorizontalOffsetorScrollToVerticalOffsetevents in WPF, but there is both aScrollViewermethod and aRoutedCommandof these names. Both the command version and the method version remember your request and execute it at the nextLayoutUpdatedevent, so if all you want to do is make sure the scrolling happens, just send the command or call the method.If you want to verify that
HorizontalOffsetorVerticalOffsethas indeed been updated as desired you can simply catch theScrollChangedEvent, which fires after the values have been updated, like this:I did not understand what you meant by "I have tried LayoutUpdated() method but it goes in a infinite loop," since you didn’t explain what "LayoutUpdated() method" is, but the above information should make the order of events clear and help you on your way to a solution. In any case, all the information you need to make your decision should be available from the
ScrollChangedevent.