.NET Development
WPF WebBrowser Zoom behaviour
Gravatar is a globally recognized avatar based on your email address. WPF WebBrowser Zoom behaviour
  Frederic Colombero Torchard
  All
  Nov 17, 2017 @ 09:12am

Hello Team Support, First of all thanks for your valuable time. I have a problem with the WPF WebBrowser control. I need to deactivate the zoom and scroll page (on touch pad or tactile screen) when i manipulate the page. Thanks for your help and valuable time. Frederic

Gravatar is a globally recognized avatar based on your email address. re: WPF WebBrowser Zoom behaviour
  Rick Strahl
  Frederic Colombero Torchard
  Nov 17, 2017 @ 01:47pm

You have to do both of these things inside of the document that is hosted in the browser via styling and script.

For scrollbars using CSS styling:

html, body { overflow: hidden }

will prevent any window scrollbars in the browser document.

For zooming you can intercept the resize event on the window.

https://stackoverflow.com/a/6168235/11197

All of this has to happen inside of the document you're displaying so either you have a template that includes this functionality, or if you don't control the HTML to display you have to inject the script and dynamically set the CSS.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: WPF WebBrowser Zoom behaviour
  Frederic Colombero Torchard
  Frederic Colombero Torchard
  Nov 20, 2017 @ 05:10am

Hello Rick, Thank you so much for your reply. Have a nice day. Best regards, Frederic

Gravatar is a globally recognized avatar based on your email address. re: WPF WebBrowser Zoom behaviour
  FoxInCloud Support - Thierry N.
  Frederic Colombero Torchard
  Nov 21, 2017 @ 04:37am

if you build the HTML page, you can try to add this in the <head> section:

<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
Gravatar is a globally recognized avatar based on your email address. re: WPF WebBrowser Zoom behaviour
  Rick Strahl
  FoxInCloud Support - Thierry N.
  Nov 21, 2017 @ 08:36pm

Unfortunately no, not in a desktop browser.

You can try it on this page which has those attributes, but you can still scroll zoom in a desktop browser. Viewport sizing is respected only on mobile browsers.

I think you can look at the resize event and then check the zoom level and reset the zoom level back to 100% or whatever you want to allow.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: WPF WebBrowser Zoom behaviour
  FoxInCloud Support - Thierry N.
  Rick Strahl
  Nov 21, 2017 @ 10:50pm

OP mentioned ‘on touch pad or tactile screen‘

Gravatar is a globally recognized avatar based on your email address. re: WPF WebBrowser Zoom behaviour
  Rick Strahl
  FoxInCloud Support - Thierry N.
  Nov 22, 2017 @ 12:25pm

Well - you have that on a full sized Windows screen... We're talking about WPF here which won't run on a mobile device.

+++ Rick ---

© 1996-2024