Get scroll event for ScrollViewer on Windows Phone

2019-04-08 18:50发布

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>
    </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

3条回答
该账号已被封号
2楼-- · 2019-04-08 19:13

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.

查看更多
混吃等死
3楼-- · 2019-04-08 19:30

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

查看更多
Fickle 薄情
4楼-- · 2019-04-08 19:33

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.

查看更多
登录 后发表回答