private static void OnPreviewMouseMove(object sender, MouseEventArgs e)
        {
            ScrollViewer scrollViewer = (ScrollViewer)sender;

            if (scrollViewer.IsMouseCaptured)
            {
                Point currentPoint = e.GetPosition(scrollViewer);

                Point scrollStartPoint = GetScrollStartPoint(scrollViewer);
                // Determine the new amount to scroll.
                Point delta = new Point(scrollStartPoint.X - currentPoint.X,
                                        scrollStartPoint.Y - currentPoint.Y);

                Point scrollStartOffset = GetScrollStartOffset(scrollViewer);
                Point scrollTarget      = new Point(scrollStartOffset.X + delta.X,
                                                    scrollStartOffset.Y + delta.Y);

                InertiaHandler inertiaProcessor = GetInertiaProcessor(scrollViewer);
                if (inertiaProcessor != null)
                {
                    inertiaProcessor.ScrollTarget = scrollTarget;
                }

                // Scroll to the new position.
                scrollViewer.ScrollToHorizontalOffset(scrollTarget.X);
                scrollViewer.ScrollToVerticalOffset(scrollTarget.Y);
            }
        }
Example #2
0
 /// <summary>
 /// Sets the InertiaProcessor property.  This dependency property 
 /// indicates ....
 /// </summary>
 private static void SetInertiaProcessor(DependencyObject d, InertiaHandler value)
 {
     d.SetValue(InertiaProcessorProperty, value);
 }
Example #3
0
 /// <summary>
 /// Sets the InertiaProcessor property.  This dependency property
 /// indicates ....
 /// </summary>
 private static void SetInertiaProcessor(DependencyObject d, InertiaHandler value)
 {
     d.SetValue(InertiaProcessorProperty, value);
 }