获取 Windows Phone 上 ScrollViewer 的滚动事件

发布于 2024-10-21 11:15:03 字数 641 浏览 1 评论 0原文

问题: 在 Windows Phone 上获取 ScrollViewer 的滚动事件

我有一个像这样的滚动查看器:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <ScrollViewer x:Name="MyScroller">
        <StackPanel>
            <!-- ... -->
        </StackPanel>
    </ScrollViewer>
</Grid>

我需要 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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

逆流 2024-10-28 11:15:03

MouseMove 在 ScrollViewer 滚动时触发:

public MainPage()
{
    InitializeComponent();

    MyScroller.MouseMove += MyScroller_MouseMove;
}

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

它不直观,因为它被命名为“鼠标”事件,并且手机上没有鼠标。但是,触摸点确实相对于 ScrollViewer 容器移动,这就是它处理滚动的方式。

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.

心作怪 2024-10-28 11:15:03

事情没那么简单,但是这个问题中写了一些滚动检测机制:

WP7 自动增长ListBox 到达最后一项

基本上看一下OnListVerticalOffsetChanged 的​​调用和使用方式。

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.

无声无音无过去 2024-10-28 11:15:03

使用 Mango,您可以观察“ScrollStates”视觉状态的变化,如以下所述 示例项目

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文