none
Is there any way to control the increment of a ScrollViewer? RRS feed

  • Question

  • When a user clicks on the up or down arrow in my ScrollViewer, I would like to scroll by a specific amount. Is there any way that I can configure the ScollViewer control to do that?
    Thanks,
    --Jeremy

    Monday, August 4, 2008 9:21 PM

Answers

  • The following code shows how to reference to to the control template generated named element:

    scrollViewer.Loaded += delegate
    {
        ScrollBar verticalScrollBar = scrollViewer.Template.FindName("PART_VerticalScrollBar", scrollViewer) as ScrollBar;
        if (verticalScrollBar != null)
        {
            verticalScrollBar.SmallChange = 2;
        }
    };

    Hope this helps
    • Marked as answer by Marco Zhou Monday, August 11, 2008 10:07 AM
    • Marked as answer by Marco Zhou Monday, August 11, 2008 10:08 AM
    • Marked as answer by Marco Zhou Monday, August 11, 2008 10:08 AM
    Friday, August 8, 2008 3:22 AM

All replies

  • You could try elaborating with ScrollBar.SmallChange property, this property could be treated as the stepping value.

    Hope this helps
    Thursday, August 7, 2008 5:16 AM
  • How do I access the scrollbar?
    Thanks,
    --Jeremy

    Thursday, August 7, 2008 3:35 PM
  • The following code shows how to reference to to the control template generated named element:

    scrollViewer.Loaded += delegate
    {
        ScrollBar verticalScrollBar = scrollViewer.Template.FindName("PART_VerticalScrollBar", scrollViewer) as ScrollBar;
        if (verticalScrollBar != null)
        {
            verticalScrollBar.SmallChange = 2;
        }
    };

    Hope this helps
    • Marked as answer by Marco Zhou Monday, August 11, 2008 10:07 AM
    • Marked as answer by Marco Zhou Monday, August 11, 2008 10:08 AM
    • Marked as answer by Marco Zhou Monday, August 11, 2008 10:08 AM
    Friday, August 8, 2008 3:22 AM
  • I tried this code but I could not see any changes in scrolling speed of scrollviewer. Also, when I scroll with mousewheel, it scrolls 3 lines on one notch and does not consider System settings for scrolling no of line when scrolled with mousewheel. Is there any way I can make scrollviewer use SystemInformation.MouseWheelScrollLines and not the default value 3? Any help would be appreciated..

    Friday, June 29, 2012 10:43 PM