嵌入式WebBrowser控件拦截水平滚动事件

时间:2021-10-12 20:44:50

We've got a Microsoft.Phone.Controls.WebBrowser embedded control inside a StackPanel, inside a PivotItem on Windows Phone 8. In a simplified form, it's basically:

我们在Windows Phone 8上的PivotItem内部的StackPanel内部有一个Microsoft.Phone.Controls.WebBrowser嵌入式控件。简单来说,它基本上是:

<Grid>
  <controls:Pivot Width="425" Margin="50,0,0,0">
    <controls:PivotItem Margin="0,0,0,0" Width="400">
      <StackPanel>
        <!-- Other stuff -->
        <phone:WebBrowser Margin="0,0,0,0" Padding="0,0,0,0" Width="400" Height="600" />
      </StackPanel>
    </controls:PivotItem>
  </controls:Pivot>
</Grid>

The problem is, unlike other controls, the WebBrowser seems to intercept all scroll events, even if no internal scrolling is required. This basically means that, once the WebBrowser control is on the screen, the only way to scroll to the next PivotItem is to tap on the headers at the top, which is a drag.

问题是,与其他控件不同,WebBrowser似乎拦截所有滚动事件,即使不需要内部滚动。这基本上意味着,一旦WebBrowser控件在屏幕上,滚动到下一个PivotItem的唯一方法是点击顶部的标题,这是一个拖动。

Some tricks I've tried include

我试过的一些技巧包括

  • Forcing the internal ScrollViewer's HorizontalScrollBarVisibility to Disabled
  • 强制内部ScrollViewer的Horizo​​ntalScrollBarVisibility为Disabled

  • Manually capturing ManipulationDelta and/or ManipulationCompleted events and propagating them up myself — they don't fire as you would expect them to
  • 手动捕获ManipulationDelta和/或ManipulationCompleted事件并自己传播它们 - 它们不像您期望的那样触发它们

  • Trying every possible permutation of the WebBrowser and parent's width to make it realize that no scrolling is necessary.
  • 尝试WebBrowser的每个可能的排列和父级的宽度,使其意识到不需要滚动。

It seems like something out of the ordinary is going on here. Any suggestions on how to change this behaviour?

看起来这里出现了一些与众不同的事情。有关如何更改此行为的任何建议?

2 个解决方案

#1


2  

Tryout this link. I think Mr.Colin Eberhardt's solution will help you to solve your issue, http://www.scottlogic.co.uk/blog/colin/2011/11/suppressing-zoom-and-scroll-interactions-in-the-windows-phone-7-browser-control/

试试这个链接。我认为Mr.Colin Eberhardt的解决方案将帮助您解决问题,http://www.scottlogic.co.uk/blog/colin/2011/11/suppressing-zoom-and-scroll-interactions-in-the-windows -phone -7-浏览器的控制/

#2


0  

Check out the solution here http://developer.nokia.com/Community/Wiki/Windows_Phone%E4%B8%ADPivot%E5%86%85%E5%B5%8CWebBrowser%E6%97%B6%E7%9A%84%E6%A8%AA%E5%90%91%E6%BB%91%E5%8A%A8%E5%A4%84%E7%90%86. Download the source code and go through the code. But the app should be Pivot app instead of Panorama app.

在这里查看解决方案http://developer.nokia.com/Community/Wiki/Windows_Phone%E4%B8%ADPivot%E5%86%85%E5%B5%8CWebBrowser%E6%97%B6%E7%9A%84 %E6%A8%AA%E5%90%91%E6%BB%91%E5%8A%A8%E5%A4%84%E7%90%86。下载源代码并完成代码。但应用程序应该是Pivot应用程序而不是Panorama应用程序。

#1


2  

Tryout this link. I think Mr.Colin Eberhardt's solution will help you to solve your issue, http://www.scottlogic.co.uk/blog/colin/2011/11/suppressing-zoom-and-scroll-interactions-in-the-windows-phone-7-browser-control/

试试这个链接。我认为Mr.Colin Eberhardt的解决方案将帮助您解决问题,http://www.scottlogic.co.uk/blog/colin/2011/11/suppressing-zoom-and-scroll-interactions-in-the-windows -phone -7-浏览器的控制/

#2


0  

Check out the solution here http://developer.nokia.com/Community/Wiki/Windows_Phone%E4%B8%ADPivot%E5%86%85%E5%B5%8CWebBrowser%E6%97%B6%E7%9A%84%E6%A8%AA%E5%90%91%E6%BB%91%E5%8A%A8%E5%A4%84%E7%90%86. Download the source code and go through the code. But the app should be Pivot app instead of Panorama app.

在这里查看解决方案http://developer.nokia.com/Community/Wiki/Windows_Phone%E4%B8%ADPivot%E5%86%85%E5%B5%8CWebBrowser%E6%97%B6%E7%9A%84 %E6%A8%AA%E5%90%91%E6%BB%91%E5%8A%A8%E5%A4%84%E7%90%86。下载源代码并完成代码。但应用程序应该是Pivot应用程序而不是Panorama应用程序。