我正在尝试创建一个包含翻转视图的应用程序,当用户有一段时间没有与之交互时,该翻转视图会自动翻转到下一页。使用基本的 DispatcherTimer 可以正常工作,当翻转视图的选择更改时会重新启动。
到目前为止一切都很好,但我也不希望计时器在用户与翻转视图中的当前项目交互时运行,比如列表视图或其他东西。我想我可以将 PointerPressed 和 PointerReleased 处理程序连接到页面,并在按下指针时停止计时器,并在释放指针时重新启动它。
这有效,除非指针位于翻转视图上:按下的处理程序被执行,但 FlipView 吞噬了所有其他指针事件,因此 PointerReleased 处理程序永远不会被执行。
我不知道如何让它工作。在 WPF 中,我只使用隧道事件,但整个概念似乎已经随着 WinRT 消失了?关于如何让它发挥作用的任何建议?
用代码更新
当然。我有一个包含翻转视图和调度程序计时器的页面:
public sealed partial class MainPage : Page
{
    private DispatcherTimer slideScrollTimer;
    public MainPage()
    {
        // Set up a timer that'll flip to the next page every 5 seconds.
        this.slideScrollTimer= new DispatcherTimer()
        {
            Interval = TimeSpan.FromSeconds(5)
        };
        slideScrollTimer.Tick += slideScrollTimer_Tick;
        slideScrollTimer.Start();
    }
    void slideScrollTimer_Tick(object sender, object e)
    {
        // When the timer runs out, go to the next page, or back
        // to the first.
        if (flipView.SelectedIndex < flipView.Items.Count - 1)
        {
            flipView.SelectedIndex++;
        }
        else
        {
            flipView.SelectedIndex = 0;
        }
    }
    private void flipView_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        // restart the timer if someone flips to a different page
        if (this.slideScrollTimer != null)
        {
            this.slideScrollTimer.Start();
        }
    }
}
基本上我想要的是每当有人触摸应用程序时重置计时器。我尝试使用 AddHandler 添加 PointerPressed/PointerReleased 处理程序,但如果您不在翻转视图上,或者只是点击它而不是滚动它或操作其内容,则释放只会触发。