If I scale a WebBrowser control (e.g. with a Viewbox) its content doesn't scale along with it. Here's a sample:
<Viewbox>
<StackPanel Background="LightBlue">
<Label Content="XAML xaml"/>
<WebBrowser Source="C:\MyPath\Test.html" />
</StackPanel>
</Viewbox>
I have a WPF application that loads and displays hundreds of local HTML files. However, the HTML appears very tiny on a 3840x2160 display because my Viewbox is unable to stretch the HTML content the way it stretches everything else. I have however noticed that I can zoom WebBrowser content with touch gestures or the mouse wheel.
What's the best way to solve this problem? I can think of several avenues to explore.
- Get WebBrowser content to scale with the control somehow.
- Programmatically zoom the WebBrowser document to match the Viewbox scaling.
- Find another way to display HTML content in WPF.
- Convert the HTML to XAML.
Microsoft made a suggestion that seems to be related to this issue and I tried implementing it as described in this answer on another question: https://stackoverflow.com/a/40657760/2122672
But that doesn't really make sense to me. It seems to have more to do with disabling the context menu than scaling the HTML.