Click here to Skip to main content
15,843,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VS2017, .Net 4.61

I'm writing an app that contains two WebBrowser controls. Each WebBRowser control is pointed to the same site, but on different servers (a pair of pi-hole DNS servers).

I want to scale the content of the entire window to fit the window size. I've tried sing a Viewbox and a RenderTransform, but the WebBrowser control ignores the scaling and still appears to report the size of the control to the web site (which is mobile enabled, BTW).

What I have tried:

0) Putting the WebBrowser into a ViewBox container with Stretch="Fill"

1) Setting the RenderTransform for the WebBrowser control

2) Setting the RenderTransform for the parent Grid control
Updated 30-Sep-18 14:22pm

It "scales" what it can:

<Window x:Class="WpfApp3.MainWindow"
         <ColumnDefinition Width="*" />
         <ColumnDefinition Width="*" />

      <WebBrowser Source="" />
      <WebBrowser Grid.Column="1"
                  Source="" />
Share this answer
#realJSOP 30-Sep-18 15:17pm    
I don't understand what you're trying to illustrate. What you posted is pretty much what I already have.
Share this answer
#realJSOP 30-Sep-18 20:33pm    
I already found that. :(

The solution discussed there is only viable for win8 and higher.

I also looked at using a winforms app and winforms interop, but the winforms web browser control is not possible because addeventlistener isn’t supported.

I think I’m just gonna have to deal with the inability to scale a web browser control.
Graeme_Grant 1-Oct-18 2:26am    
Yes, I found similar ... The WPF web browser is actually the same one used with WinForms. Have you looked at CefSharp - Fast web browser for WinForms and WPF Apps[^]?
#realJSOP 1-Oct-18 5:10am    
I don't think they are the same. The WPF version works fine, but the WinForms version complains about the javascript function "addEventListener". I know about the CEF thing, but haven't tried it yet.
Graeme_Grant 1-Oct-18 5:22am    
for Winforms you use a shim, for WPF you don't ... this could be why... I also read it somewhere from one of the MS devs... can't remember where ...
Richard Deeming 3-Oct-18 13:46pm    
Graeme is correct - the WPF control is a thin wrapper around the ActiveX control, which is why it doesn't respect the WPF transforms.
Source code[^]

It's also going to be stuck in IE7 mode by default, unless you change the registry on every computer where your application runs[^].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900