lor*_*s91 7 c# wpf scrollviewer scrollview windows-8
我在平板电脑华硕ME400 Intel Atom Z2760上运行我的桌面应用程序WPF.所有工作都正常,但是当我使用scrollviewer时,用手指在滚动结束时用手指滚动移动(简化平移模式horizontalOnly),窗口移动,你会看到任务栏片刻.如果我用手指滚动,直到在滚动条中建立后才会看到效果.
我怎么能避免这个窗口运动?当我在滚动条的末尾滚动时,如何锁定窗口并且不允许移动?
在ScrollViewer已启用平移的对象中,为其注册新事件ManipulationBoundaryFeedback.
<ScrollViewer PanningMode="Both" ManipulationBoundaryFeedback="ScrollViewer_ManipulationBoundaryFeedback">
<!-- your content is here... -->
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)
在代码隐藏中,您必须通过将Handled属性设置为true:来处理事件:
void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
e.Handled = true;
}
Run Code Online (Sandbox Code Playgroud)
(通过将Handled属性设置为true,我们实际上告诉我们事件已由我们处理,因此我们在视觉树中停止消息的冒泡过程,然后它将到达Window/ Application- 无论哪个会导致抖动.)