Im using WPF ScrollViewer to host some controls. I would really like it to interact, as if on a touch device, where it slowly tidies up when you pull it too far.
It does not have a scrollbar - I have a manual mouse scroll with click and drag using this code:
Point currentPoint = e.GetPosition(this);
Point delta = new Point(scrollStartPoint.X - currentPoint.X, scrollStartPoint.Y - currentPoint.Y);
if (Math.Abs(delta.X) < PixelsToMoveToBeConsideredScroll &&
Math.Abs(delta.Y) < PixelsToMoveToBeConsideredScroll)
return;
scrollTarget.X = scrollStartOffset.X + delta.X;
scrollTarget.Y = scrollStartOffset.Y + delta.Y;
sv.ScrollToHorizontalOffset(scrollTarget.X);
sv.ScrollToVerticalOffset(scrollTarget.Y);
Is there an easy way to do this? Currently, it just acts like a normal scroll text box and will not go beyond its normal range and not slow it down.
source
share