private void Canvas_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { var pos = e.GetPosition(zoomCanvas); var cl = Canvas.GetLeft(this.zoomThumb); var ct = Canvas.GetTop(this.zoomThumb); double scale, xOffset, yOffset; this.InvalidateScale(out scale, out xOffset, out yOffset); var dl = pos.X - cl - (zoomThumb.Width / 2); var dt = pos.Y - ct - (zoomThumb.Height / 2); scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + dl / scale); scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + dt / scale); }
private void Thumb_DragDelta(object sender, DragDeltaEventArgs e) { if (DesignSurface != null) { if (scrollViewer != null) { double scale, xOffset, yOffset; this.InvalidateScale(out scale, out xOffset, out yOffset); scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + e.HorizontalChange / scale); scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + e.VerticalChange / scale); } } }