Disabling Navigation Flicks in WPF

Posted by Brian Genisio's House Of Bilz on Geeks with Blogs See other posts from Geeks with Blogs or by Brian Genisio's House Of Bilz
Published on Wed, 02 Jun 2010 15:10:16 GMT Indexed on 2010/06/02 16:25 UTC
Read the original article Hit count: 327

Filed under:

I am currently working on a multi-touch application using WPF.  One thing that has been irritating me with this development is an automatic navigation forward/back command that is bound to forward and backwards flicks.  Many of my touch-based interactions were being thwarted by gestures picked up by WPF as navigation.  I just wanted to disable this behavior.

My programmatic back/forward calls are not affected by this change, which is nice.  Here is how I did it:  In my main window, I added the following command bindings:

<NavigationWindow.CommandBindings>
    <CommandBinding Command="NavigationCommands.BrowseBack" Executed="DoNothing" />
    <CommandBinding Command="NavigationCommands.BrowseForward" Executed="DoNothing" />
</NavigationWindow.CommandBindings>

Then, the DoNothing method in the code-behind does nothing:

private void DoNothing(object sender, ExecutedRoutedEventArgs e) { }


There may be a better way to do this, but I haven’t found one.

© Geeks with Blogs or respective owner