Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent touch feedback on a Winforms WebBrowser in WPF?

I'm using the WinForms version of <WebBrowser> in my WPF app, a la <WindowsFormsHost> because in general it works a lot better than the Windows.Controls version. However I have one problem that has to do with touch screens.

Normally I set the ManipulationBoundaryFeedback event handler on controls to immediately handle the event, thereby preventing any boundary feedback, and I've tried to do so with this code:

MainWindow.xaml

<WindowsFormsHost IsManipulationEnabled="True" ManipulationBoundaryFeedback="WindowsFormsHost_OnManipulationBoundaryFeedback">
    <forms:WebBrowser />
</WindowsFormsHost>

MainWindow.xaml.cs

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

On ordinary WPF controls, generally speaking, this works. And what I mean by "works" is that if you use your finger on the touch screen and drag up or down, you don't get the effects of touch screen intertia; that is, it doesn't shift the entire window up or down once you hit the boundary.

Here's a picture to illustrate what's happening:

animated gif of touch screen issue

As you can see, if I drag down within the browser, it pulls the entire window with it. What can I do to prevent this?

like image 269
soapergem Avatar asked Feb 03 '26 19:02

soapergem


1 Answers

You could turn off this behavior for the whole system:

Open registry ( run regedit command ) and set HKEY_CURRENT_USER\Software\Microsoft\Wisp\Touch Bouncing to 0; if HKEY_CURRENT_USER\Software\Microsoft\Wisp\Touch not exist Bouncing item, add it( DWORD type, Not QWORD or String) and set it value to 0.

However, this is not a good approch, even if it solve my problem. Look at this manipulationboundaryfeedback-does-not-work-in-webbrowser-in-wpf.

like image 87
chengzi Avatar answered Feb 06 '26 09:02

chengzi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!