locked
Can mouse scrolling work with a scrollviewer within an appbar? RRS feed

  • Question

  • The C# Windows 8 app i am currently working on requires a scrollviewer to hold items within the top appbar. Everything works as expected when using touch, but mouse scroll does not work with the scrollviewer. Even with the scrollbar set to "Visible", when hovering over the scrollbar mouse scrolling does not work.

    I have tested other items (gridviews, etc...) in the topp appbar to see if mouse scrolling will work and they seem to work fine. Only the scrollviewer's pointerWheelChanged event never seems to fire. Does any have any suggestions how to fix this issue?

    Thanks in advance.

    (sidenote: the only workaround I have come up with so far is to actually replace the scrollviewer with a gridview and use this gridview to hold my top appbar's layout... this workaround works but is obviously not the ideal solution and if possible, I would much rather use the correct scrollviewer page element)

    • Edited by twubneh Wednesday, January 8, 2014 6:50 PM workaround clarification
    Wednesday, January 8, 2014 6:38 PM

Answers

  • Hi twubneh,

    Mouse scroll does not work with ScrollViewer? I tried with following code and it works fine for me:

        <Page.TopAppBar>
            <AppBar Height="100">
                <ScrollViewer HorizontalScrollBarVisibility="Visible">
                    <StackPanel Orientation="Horizontal">
                        <Button Content="Home" Width="140" Height="180" />
                        <Button Content="Page 1" Width="1400" Height="80" />
                        <Button Content="Page 2" Width="140" Height="80" />
                    </StackPanel>
                </ScrollViewer>
            </AppBar>
        </Page.TopAppBar>

    The problem might be there is something in your ScrollViewer handle the mouse event, and not pass the mouse action to ScrollViewer, read this for more: Events and routed events overview. Try to validate what has grabbed your event, and if possible, share some code snippet with us for a better analysis.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by twubneh Thursday, January 9, 2014 4:37 PM
    Thursday, January 9, 2014 2:12 AM
    Moderator
  • From looking at your simple example I was able to determine exactly what the issue was.

    Originally I thought that the mouse scroll action was not reaching the scrollviewer at all but I was wrong. When I tried your example I saw that the vertical scrolling recieves the mouse event before the horizontal scrolling. My scrollviewer had no need for vertical scrolling, but since vertical scroll was set to "Enabled" it was swallowing the mouse scroll event and preventing horizontal scrolling from happening. Once I set vertical scrolling to "Disabled" the horizontal scrolling worked as expected within the appbar.

    Thanks for the help!

    Thursday, January 9, 2014 4:37 PM

All replies

  • Hi twubneh,

    Mouse scroll does not work with ScrollViewer? I tried with following code and it works fine for me:

        <Page.TopAppBar>
            <AppBar Height="100">
                <ScrollViewer HorizontalScrollBarVisibility="Visible">
                    <StackPanel Orientation="Horizontal">
                        <Button Content="Home" Width="140" Height="180" />
                        <Button Content="Page 1" Width="1400" Height="80" />
                        <Button Content="Page 2" Width="140" Height="80" />
                    </StackPanel>
                </ScrollViewer>
            </AppBar>
        </Page.TopAppBar>

    The problem might be there is something in your ScrollViewer handle the mouse event, and not pass the mouse action to ScrollViewer, read this for more: Events and routed events overview. Try to validate what has grabbed your event, and if possible, share some code snippet with us for a better analysis.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by twubneh Thursday, January 9, 2014 4:37 PM
    Thursday, January 9, 2014 2:12 AM
    Moderator
  • From looking at your simple example I was able to determine exactly what the issue was.

    Originally I thought that the mouse scroll action was not reaching the scrollviewer at all but I was wrong. When I tried your example I saw that the vertical scrolling recieves the mouse event before the horizontal scrolling. My scrollviewer had no need for vertical scrolling, but since vertical scroll was set to "Enabled" it was swallowing the mouse scroll event and preventing horizontal scrolling from happening. Once I set vertical scrolling to "Disabled" the horizontal scrolling worked as expected within the appbar.

    Thanks for the help!

    Thursday, January 9, 2014 4:37 PM