locked
Horizontal swipe gesture on ScrollViewer with C# in store apps RRS feed

  • Question

  • In my app I have a ScrollViewer (which scrolls vertically) within which I host a Grid which in turn hosts an RochTextBlock. I want the ScrollViewer to scroll vertically as normal, but I also want to detect horizontal swipe in the current window.

    I have tried a lot of options such as using GestureRecognizer or using various Manipulation events on the UI elements. And I can get to detect the swipes but then I loose the ability to scroll vertically using the touch gesture. Here is how my XAML looks. I would be grateful for someone guiding me.

        <ScrollViewer Name="scrollViewer">
            <Grid Name="grid1"
                  HorizontalAlignment="Center">

                <RichTextBlock Name="richTextblock"
                               HorizontalAlignment="Center"
                               MaxWidth="800"/>
            </Grid>
        </ScrollViewer>

    thanks,


    Sameer V.




    • Edited by Sameer.V Thursday, March 14, 2013 5:10 PM reduce ambiguity.
    Thursday, March 14, 2013 4:41 PM

Answers

All replies

  • Hi Sameer,

    I discussed this in Where did all my gestures go?

    --Rob

    • Marked as answer by Aaron Xue Wednesday, March 27, 2013 9:35 AM
    Thursday, March 14, 2013 7:05 PM
    Moderator
  • Thanks for replying Rob.

    That's a useful post but unfortunately it doesn't solve my problem. There are no NO_SCROLL areas in my app, It's a RichTextBlock hosted inside an ScrollViewer. I want to be able to scroll vertically, and capture the Horizontal swipe so I can slide in some auxiliary UI from the right-hand-side.

    Help! 


    Sameer V.

    Thursday, March 14, 2013 9:10 PM
  • Hi Sameer,

    As I mention in the last paragraph, there is no good solution for the scenario where you need both scrolling and custom cross-sliding. You will need to disable the ScrollViewer's scrolling so you can get the gestures and then handle the scrolling yourself by calling ScrollToVerticalOffset.

    --Rob

    Thursday, March 14, 2013 9:24 PM
    Moderator
  • That could work. Let me bang my head a little more :-) I'll update this thread if I find any success.

    Thanks for your help Rob.

    cheers


    Sameer V.

    Thursday, March 14, 2013 9:43 PM