locked
ScrollViewer scroll horizontal mouse wheel RRS feed

  • Question

  • Hi, I have a ScrollViewer which contains a long rectangle. How enable scroll horizontally using the mouse wheel on Windows 8 RTM?

    I found this solution: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/279e29b8-e439-4d1a  but the event PreviewMouseWheel is missing in the ScrollViewer. In the RTM version exists PointerWheelChanged event but with mouse wheel this isn't fired.

    Full code:

    <Page x:Class="WebViewTest.ScrollPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:WebViewTest" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled"> <Rectangle Width="4000" Fill="SteelBlue" Margin="24" /> </ScrollViewer> </Grid> </Page

    Wednesday, October 3, 2012 9:37 AM

Answers

  • use:

    <ScrollViewer Style={StaticResource HorizontalScrollViewerStyle}>
    </ScrollViewer>

    • Proposed as answer by Tanu Singhal Wednesday, October 3, 2012 5:44 PM
    • Marked as answer by Jesse Jiang Friday, October 5, 2012 8:02 AM
    Wednesday, October 3, 2012 9:55 AM

All replies

  • use:

    <ScrollViewer Style={StaticResource HorizontalScrollViewerStyle}>
    </ScrollViewer>

    • Proposed as answer by Tanu Singhal Wednesday, October 3, 2012 5:44 PM
    • Marked as answer by Jesse Jiang Friday, October 5, 2012 8:02 AM
    Wednesday, October 3, 2012 9:55 AM
  • Thanks, it works :)
    Wednesday, October 3, 2012 10:19 AM
  • This was a big help, but I had to put it in quotes to make it work.
    <ScrollViewer Style="{StaticResource HorizontalScrollViewerStyle}">
    </ScrollViewer>


    Thursday, December 6, 2012 4:17 AM
  • Sorry to hijack a thread, but I'm having an issue with the provided solution.

    It seems to work with a USB mouse, and works with my trackpad in the simulator, but when deployed or ran on Local Machine it doesn't work at all..

    What gives? The trackpad works in other apps I've downloaded, why won't it work in mine? Is there a separate event I should be aware of, and handle scrolling manually?

    Sunday, December 23, 2012 10:50 PM