I have a metro styled app with a scrollviewer. Now I would like to scroll to a position when the user clicks a button. I tried:
MainScrollViewer.ScrollToHorizontalOffset(x);
But then its “jumping” there quickly. I want to have a smooth animation up to x.
There is no API out of the box that would allow you to do that.
There is also no property that you could target with an animation.
You would need to either use frame-based animation (basically figure out where you are in the timeline and on each CompositionTarget.Rendering event – update the offset) or create an attached dependency property that calls ScrollToHorizontalOffset when its value changes and target that property with an animation.