How to stop a WPF Window from moving using Touch by removing the ManipulationBoundaryFeedback

When using Touch in WPF it is possible to scroll lists. It’s just that the Window is moving to give Feedback when you are reaching the end of the list. This is not always what you want. To make your application ignore this behavior you can mark the ManipulationBoundaryFeedback event handled:

<Grid :Name="LayoutRoot" 
    ManipulationBoundaryFeedback="ManipulationBoundaryFeedbackHandler">

<DataGrid
    ScrollViewer.CanContentScroll ="False"
    ScrollViewer.PanningMode="VerticalOnly"
    ScrollViewer.PanningRatio="2"
    ScrollViewer.PanningDeceleration="1000"
    ScrollViewer.VerticalScrollBarVisibility="Hidden">
        …
</DataGrid>

.. your application is here…

</Grid>

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

The event is bubbling only, so if you place the event handler on your LayoutRoot it should work for all lists.

Actually there is also a System settings in the Panning Tab in the Pen and Touch settings dialog. This is a setting the end users can choose.

Njoy!

7 gedachten over “How to stop a WPF Window from moving using Touch by removing the ManipulationBoundaryFeedback”

  1. Hi, any idea why this does not work with a WPF WebBrowser when scrollbars are displayed? Thank you.

    1. If you mean with WPFWebbrowser a Webbrowser Control in a WPF-application, it Will be because this behavior is implemented on a Window control, not on a Webbrowser Control. Either implement this solution on the Window or you will have to find a way to stop the Webbrowser Control from moving the Window… Succes!

  2. Thank you for your response. I created a WPF application with a WPF WebBrowser and implemented the ManipulationBoundaryFeedback event at the Window level. On the same window I have a ListBox. It works for ListBox but not for the WebBrowser. I will try to find a way to stop the WebBrowser control from moving the window – any help is appreciated.

Reacties zijn gesloten.