Gepost door: antonidol | dinsdag 24 januari 2012

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!


Responses

  1. Thank you SOOOOO much

  2. […] https://antonidol.wordpress.com/2012/01/24/how-to-stop-a-wpf-window-from-moving-by-removing-the-manip&#8230; […]

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

    • 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!

  4. 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.


Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit / Bijwerken )

Twitter-afbeelding

Je reageert onder je Twitter account. Log uit / Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit / Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit / Bijwerken )

Verbinden met %s

Categorieën

%d bloggers op de volgende wijze: