如何让WPF WebBrowser水平和垂直增长?
在 WPF 中,我们使用 WebBrowser 控件来查看 HTML 内容。 当我们将控件放置在窗口上时,它会随着窗口的增长/缩小而水平增长。 然而,我们还没有找到一种方法让控件随窗口垂直增长。 我们正在寻找一些示例代码,这些代码将允许 WebBrowser WPF 控件随窗口垂直和水平增长。
In WPF, we are using a WebBrowser control to view HTML content. When we place the control on our window, it grows horizontally with the window as it grows/shrinks. However, we have not found a way to make the control grow vertically with the window. We are looking for some sample code that will allow the WebBrowser WPF control to grow both vertically and horizontally with the window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 WPF 并希望随窗口一起增长,神奇的起点是将 Margin 设置为 0 并避免设置宽度和高度。 (您可以使边距等于另一个数字,但从零开始,先看看它的外观!)
另一个选择是使用停靠面板,并将最后一个子填充设置为 true,其中 Web 浏览器控件是最后一个元素(如您向下阅读页面 - 它不必是呈现的 UI 中的最后一个元素。
With WPF and wanting to grow with the window, the magical starting point is to set the Margin to 0 and avoid setting width and height. (You can have margin equal to another number, but start with zero and see how it looks first!)
Another option is to use a dock panel with last child fill set to true, where the web browser control is the last element (as you read down the page - it doesn't have to be the last element in the rendered UI.