防止 WPF WebBrowser 显示内容的滚动条
我正在使用 WPF WebBrowser 组件显示一些非常简单的 HTML 内容。但是,由于我事先不知道内容大小,因此当我加载某些数据集时,我当前会在控件上看到滚动条。
基本上,我如何强制(或以其他方式实现强制)WebBrowser 扩大尺寸,以便显示所有内容而不需要滚动条?
I'm using the WPF WebBrowser component to display some very simple HTML content. However, since I don't know the content size in advance, I'm currently getting scrollbars on the control when I load certain datasets.
Basically, how can I force (or otherwise effect the equivalent of forcing) the WebBrowser to expand in size so that all content is displayed without the need for scrollbars?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想您可以通过其 Document 属性获取网络浏览器组件内容的宽度和高度,该属性应该是 mshtml.HTMLDocument 类型。我相信您应该能够使用 body 或 documentElement 属性来获取所需的大小;像这样的:
希望这有帮助,问候
I guess you can get width and height of the webbrowser component content through its Document property which should be of mshtml.HTMLDocument type. I believe you should be able to use body or documentElement properties to get needed sizes; smth like this:
hope this helps, regards
先前解决方案的问题在于它更改了控件大小,并且由于浏览器控件无法被剪切并且始终位于其他 WPF 元素之上,因此它可能会覆盖其他元素。
这是我的解决方案:
问候,
阿萨夫
The problem with previous solution is that it changes the control size and since the browser control cannot be clipped and is always on top of other WPF elements, it may cover the other elements.
Here is my solution:
Regards,
Assaf