开发者

Get scroll event for ScrollViewer on Windows Phone

Question: Get scroll event for ScrollViewer on Windows Phone

I have a scrollviewer like so:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <ScrollViewer x:Name="MyScroller">
        <StackPanel>
            <!-- ... -->
        </StackPanel>
开发者_如何学JAVA    </ScrollViewer>
</Grid>

I need the event for when the scrolling occurs for MyScroller:

// MyScroller.Scroll += // <-- "Scroll" event does not exist on ScrollViewer
MyScroller.MouseWheel += MyScroller_MouseWheel; // Does not fire on scroll
MyScroller.ManipulationDelta += MyScroller_ManipulationDelta; // Fires for pinch-zoom only


MouseMove fires when ScrollViewer is scrolled:

public MainPage()
{
    InitializeComponent();

    MyScroller.MouseMove += MyScroller_MouseMove;
}

void MyScroller_MouseMove(object sender, MouseEventArgs e)
{
    throw new NotImplementedException();// This will fire
}

It isn't intuitive, since it is named as a "mouse" event and there is no mouse on the phone. The touch point does move, however, relative to the ScrollViewer container, which is how it can handle scrolling.


It's not that simple, but there's a few scroll detection mechanisms written in this question:

WP7 Auto Grow ListBox upon reaching the last item

Basically take a look at the way OnListVerticalOffsetChanged is called and used.


With Mango, you can watch for the "ScrollStates" visual state to change as described in this sample project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜