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.
我正在我的WPF应用程序中使用WinForms版本的
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
MainWindow.xaml
<WindowsFormsHost IsManipulationEnabled="True" ManipulationBoundaryFeedback="WindowsFormsHost_OnManipulationBoundaryFeedback">
<forms:WebBrowser />
</WindowsFormsHost>
MainWindow.xaml.cs
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.
一般的WPF控制,一般来说,这是有效的。我所说的"作品"是指如果你用手指在触摸屏上上下拖动,你就不会得到触摸屏内部的效果;也就是说,当你到达边界时,它不会上下移动整个窗口。
Here's a picture to illustrate what's happening:
这里有一张图片来说明正在发生的事情:
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?
如你所见,如果我在浏览器中拖拽,它会拖拽整个窗口。我能做些什么来避免这种情况?
2 个解决方案
#1
0
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
.
打开注册表(运行regedit命令),设置HKEY_CURRENT_USER\软件\Microsoft\Wisp\Touch弹跳为0;如果HKEY_CURRENT_USER\软件\Microsoft\Wisp\Touch不存在弹跳项,则添加它(DWORD类型,而不是QWORD或String)并将它的值设置为0。
This is not a good approch, through it solve my problem. And this answer is from manipulationboundaryfeedback-does-not-work-in-webbrowser-in-wpf.
这不是一个好的方法,通过它可以解决我的问题。这个答案来自于operationborder - feedback-does-not-work in- webbrowserin -wpf。
#2
0
Not sure if you still need this answer but to prevent this unnecessary behavior simply inherit WindowsFormsHost class and override OnManipulationBoundaryFeedback like this:
不确定您是否还需要这个答案,但是为了防止这种不必要的行为,只需继承WindowsFormsHost类,并重写这样的操作边界反馈:
public class MyClass : WindowsFormsHost
{
// Override is optional to remove unnecessary behavior
protected override void OnManipulationBoundaryFeedback(ManipulationBoundaryFeedbackEventArgs e)
{
// uncomment this to use base class implementation
//base.OnManipulationBoundaryFeedback(e);
e.Handled = true;
}
}
Edited
编辑
I have made a small test and added this code for my control
我做了一个小测试,并为我的控件添加了这个代码
protected override void OnManipulationBoundaryFeedback(ManipulationBoundaryFeedbackEventArgs e)
{
Debug.WriteLine("OnManipulationBoundaryFeedback");
}
private void MyControl_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
Debug.WriteLine("MyControl_ManipulationBoundaryFeedback");
}
and Output was the following
输出是这样的
OnManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
So you can see that OnManipulationBoundaryFeedback launched first and then it invokes ManipulationBoundaryFeedbackEvent handlers
你可以看到onmanipulation ationboundary - feedback首先被启动,然后它调用了controationborder - feedbackevent处理程序
#1
0
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
.
打开注册表(运行regedit命令),设置HKEY_CURRENT_USER\软件\Microsoft\Wisp\Touch弹跳为0;如果HKEY_CURRENT_USER\软件\Microsoft\Wisp\Touch不存在弹跳项,则添加它(DWORD类型,而不是QWORD或String)并将它的值设置为0。
This is not a good approch, through it solve my problem. And this answer is from manipulationboundaryfeedback-does-not-work-in-webbrowser-in-wpf.
这不是一个好的方法,通过它可以解决我的问题。这个答案来自于operationborder - feedback-does-not-work in- webbrowserin -wpf。
#2
0
Not sure if you still need this answer but to prevent this unnecessary behavior simply inherit WindowsFormsHost class and override OnManipulationBoundaryFeedback like this:
不确定您是否还需要这个答案,但是为了防止这种不必要的行为,只需继承WindowsFormsHost类,并重写这样的操作边界反馈:
public class MyClass : WindowsFormsHost
{
// Override is optional to remove unnecessary behavior
protected override void OnManipulationBoundaryFeedback(ManipulationBoundaryFeedbackEventArgs e)
{
// uncomment this to use base class implementation
//base.OnManipulationBoundaryFeedback(e);
e.Handled = true;
}
}
Edited
编辑
I have made a small test and added this code for my control
我做了一个小测试,并为我的控件添加了这个代码
protected override void OnManipulationBoundaryFeedback(ManipulationBoundaryFeedbackEventArgs e)
{
Debug.WriteLine("OnManipulationBoundaryFeedback");
}
private void MyControl_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
Debug.WriteLine("MyControl_ManipulationBoundaryFeedback");
}
and Output was the following
输出是这样的
OnManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
OnManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
MyControl_ManipulationBoundaryFeedback
So you can see that OnManipulationBoundaryFeedback launched first and then it invokes ManipulationBoundaryFeedbackEvent handlers
你可以看到onmanipulation ationboundary - feedback首先被启动,然后它调用了controationborder - feedbackevent处理程序