Adam Benoit
Adam Benoit

Reputation: 386

How to stop ScrollViewer from scrolling down

I need to make the ScrollViewer to only scroll down.

I have created a scrollviewer in Xaml and have populated it with a stackpanel full of rectangles in code. I then start the user at the bottom and want them to use a "walking" motion with their fingers (like a bass player) to scroll to the top but do not want them to be able to scroll back to the bottom.

My Xaml looks like this:

<ScrollViewer Height="730" HorizontalAlignment="Left" Margin="6,6,0,0" Name="scrollViewer1" VerticalAlignment="Bottom" Width="462">
    <StackPanel Name="TrackStackPanel">

    </StackPanel>
</ScrollViewer>

But since it is filled in code, need to accomplish as much as I can in code.

Upvotes: 1

Views: 1028

Answers (1)

ColinE
ColinE

Reputation: 70142

I would try disabling vertical scrolling via VerticalScrollBarVisibility="disabled" - handle the gestures, then scroll accordingly by setting [ScrollToVerticalOffset].

If this does not work, try placing a layer (a Grid for example) above your ScrollViewer, so that it will receive all the gestures, then do as above, scroll via ScrollToVerticalOffset.

Upvotes: 4

Related Questions