it\'s done well to scroll by mouse-wheel or scrollbar seed-dragging. but scrolling by mouse-dragging contents on scroll view is not done. How can i implement this action?
I found a way of resolving this. It's following...
Point scrollMousePoint = new Point();
double hOff = 1;
private void scrollViewer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
scrollMousePoint = e.GetPosition(scrollViewer);
hOff = scrollViewer.HorizontalOffset;
scrollViewer.CaptureMouse();
}
private void scrollViewer_PreviewMouseMove(object sender, MouseEventArgs e)
{
if(scrollViewer.IsMouseCaptured)
{
scrollViewer.ScrollToHorizontalOffset(hOff + (scrollMousePoint.X - e.GetPosition(scrollViewer).X));
}
}
private void scrollViewer_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
scrollViewer.ReleaseMouseCapture();
}
private void scrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + e.Delta);
}
thanks!