7

我在平板电脑 ASUS ME400 Intel Atom Z2760 上运行我的桌面应用程序 WPF。一切正常,但是当我使用scrollviewer时,在用手指滚动结束时用手指滚动移动(支持平移模式horizo​​ntalOnly),窗口移动,你会看到任务栏片刻。如果我用手指滚动看不到效果,直到在滚动条中找到才到达。

我怎样才能避免这种窗口移动?当我在滚动条末尾滚动时,如何锁定我的窗口并且不允许移动?

4

1 回答 1

10

ScrollViewer启用平移的对象中,为ManipulationBoundaryFeedback.

<ScrollViewer PanningMode="Both" ManipulationBoundaryFeedback="ScrollViewer_ManipulationBoundaryFeedback">
    <!-- your content is here... -->
</ScrollViewer>

在代码隐藏中,您必须通过将Handled属性设置为来处理事件true

void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
    e.Handled = true;
}

(通过将Handled属性设置为true,我们实际上是在告诉我们该事件已被我们处理,因此我们将在消息到达Window/之前停止消息在可视树中的冒泡过程Application- 无论哪个会导致抖动。)

于 2016-05-03T09:25:18.830 回答