locked
Getting ScrollViewer to horizontally scroll with mouse wheel

    Question

  • In my application I have a ScrollViewer which contains a user control that has a long list of information that I want to horizontally scroll through. When I test my application in the simulator I can scroll horizontally using the touch emulation. When I run the application on my local machine I cannot scroll horizontally using either the mouse scroll wheel or dragging with the mouse pointer. The only way I can get the content to scroll is when I show the horizontal scrollbar, then I can scroll using the mouse point only. I really want to be able to scroll using the mouse wheel and not expose the horizontal scrollbar, like you can on the Start screen.  I thought that horizontal scrolling with the mouse wheel would be the default behavior for a ScrollViewer.

    How can I get the scrolling to work this way?

     

    <ScrollViewer  VerticalScrollBarVisibility="Disabled" HorizontalAlignment="Left" Height="100" Margin="420,620,0,0" VerticalAlignment="Top" Width="637">
                <local:ViewerContent  d:LayoutOverrides="Width, Height" Height="43" Width="2230" />
    </ScrollViewer>
    

     
    Saturday, September 8, 2012 6:56 PM

Answers

  • The scroll wheel will scroll the control if there is a ScrollBar visible: set the HorizontalScrollBarVisibility property to Auto (or Visible). With that set you shouldn't have problems, and I can scroll with that added to your ScrollViewer Xaml with a gradient Rectangle as content.

    I'm not sure what you mean by "not expose the horizontal scrollbar, like you can on the Start screen." The Start screen does show a horizontal scrollbar when scrolling with the mouse. The ScrollViewer with HorzontalScrollBarVisibility="Auto" gives the same behavior.

    --Rob

    Monday, September 10, 2012 9:56 PM
    Owner

All replies

  • The scroll wheel will scroll the control if there is a ScrollBar visible: set the HorizontalScrollBarVisibility property to Auto (or Visible). With that set you shouldn't have problems, and I can scroll with that added to your ScrollViewer Xaml with a gradient Rectangle as content.

    I'm not sure what you mean by "not expose the horizontal scrollbar, like you can on the Start screen." The Start screen does show a horizontal scrollbar when scrolling with the mouse. The ScrollViewer with HorzontalScrollBarVisibility="Auto" gives the same behavior.

    --Rob

    Monday, September 10, 2012 9:56 PM
    Owner
  • Thanks for the reply, Rob. I'm converting an existing WP7 application and some of my implementations for the phone are very different than what I should be doing for the Metro environment. On the phone application I had some horizontal scrollable content and there was no room for a scrollbar in the layout. I realize that trying to reproduce the same on Windows 8 is not good design. I change over to using a GridView instead of a ScrollViewer, as I found that easier to work with.
    Tuesday, September 11, 2012 2:24 PM