Tablet WPF Windows Desktop Application - Scrolling

2019-06-20 08:07发布

问题:

I'm running my desktop application WPF on tablet ASUS ME400 Intel Atom Z2760. All working properly, but when I use scrollviewer, scroll movement with finger (abilitate panning mode horizontalOnly) at the end of scroll with finger, the window moves and you see the taskbar for a moment. The effect is not seen if I scroll with my finger, did not arrive until founded in the scrollbar.

How i can avoid this window movement? How I can lock my windows and do not permit to move when I scroll at the end of scrollbar?

回答1:

In the ScrollViewer object, where you've enabled the panning, register a new event for ManipulationBoundaryFeedback.

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

In the codebehind, you have to handle the event, by setting the Handled property to true:

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

(By setting the Handled property to true, we are actually telling that the event has got handled by us, so we are stopping the message's bubbling process in the Visual Tree, before it would reach the Window/Application - whichever would cause the shaking.)