I think there are two ways to do this. 1, WebBrowser is based on IE 9, so WebBrowser is also supporting the latest HTML5 standards. However, there are many controls in HTML that work with handheld behaviors like pan and zoom in browser, and you can set viewport metadata elements in HTML. For example, add the following HTML code to your HTML file header. <meta name= "viewport" content= "User-scalable=no"/>2, the Webbroswer control is composed of a tree structure such as: \-webbrowser
\- Border
\-border
\-panzoomcontainer
\-grid
\-border (*)
& Nbsp;\-contentpresenter
\-tilehost
where Tilehost is the original IE9 component, Tilehost does not handle all manipulation related events, but is handled by Panzoomcontainer, converting these events to handheld and then transferring the results to Tilehost. In other words we can interrupt the related Manipulationg event transmission to Panzoomcontainer. When these events are not bubble up to Panzoomcontainer, when these events are set to already processed. The key steps of this approach are 2 steps: 1, you need to find the border control from the Webbroswer component tree. 2, handles manipulation related events, and sets the event has been processed e.handled = true;
For example: |
Using Linqtovisualtree;
public class Webbrowserhelper
{
Public WebBrowser _browser;
<summary>
Gets or sets whether to suppress the scrolling of
The WebBrowser control;
</summary>
public bool scrolldisabled {get; set;}
Public Webbrowserhelper (WebBrowser browser)
{
_browser = browser;
Browser. Loaded + = new Routedeventhandler (browser_loaded);
}
private void Browser_loaded (object sender, RoutedEventArgs e)
{
var border = _browser. Descendants<border> (). Last () as Border;
Border. Manipulationdelta + = Border_manipulationdelta;
Border. manipulationcompleted + = border_manipulationcompleted;
}
private void Border_manipulationcompleted (object sender,
ManipulationCompletedEventArgs e)
{
Suppress zoom
if (e.finalvelocities.expansionvelocity.x! = 0.0 | |
E.finalvelocities.expansionvelocity.y! = 0.0)
E.handled = true;
}
private void Border_manipulationdelta (object sender,
Manipulationdeltaeventargs e)
{
Suppress zoom
if (e.deltamanipulation.scale.x! = 0.0 | |
E.deltamanipulation.scale.y! = 0.0)
E.handled = true;
Optionally suppress scrolling
if (scrolldisabled)
{
if (e.deltamanipulation.translation.x! = 0.0 | |
E.deltamanipulation.translation.y! = 0.0)
E.handled = true;
}
}
}
Detailed Description: http://wp.662p.com/thread-7952-1-1.html