【发布时间】:2014-06-24 21:58:35
【问题描述】:
编辑:我将属性更改为隐藏,但它仍然显示。
我已经阅读了这个问题的大约 10 种不同的变体,它们似乎都有不同的解决方案,但没有一个对我有用。
我有一个带有 WebBrowser 的 WPF 窗口,如下所示(如您所见,我已经非常彻底地尝试确保隐藏垂直滚动条):
<Window x:Class="ZendeskWebApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="460" Width="700" ScrollViewer.VerticalScrollBarVisibility="Hidden">
<Grid ScrollViewer.VerticalScrollBarVisibility="Hidden">
<WebBrowser Name="_browser" ScrollViewer.VerticalScrollBarVisibility="Hidden"/>
</Grid>
</Window>
在后面的代码中,我正在加载一个本地 html 页面:
public MainWindow()
{
InitializeComponent();
this._browser.Source = new Uri(new System.IO.FileInfo("AskAQuestion.htm").FullName);
}
这是页面上唯一的内容:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Ask A Question</title>
</head>
<body>
<div>
<iframe src="http://mysite.zendesk.com/account/dropboxes/123456" width="100%" height="100%" frameborder=0></iframe>
</div>
</body>
</html>
应该显示的唯一滚动条是 iframe 滚动条,但只要页面在 iframe 中加载,就会加载一个垂直滚动条。当没有加载页面时没有滚动条。
为什么会这样?
【问题讨论】:
-
只是一个想法,但可能是因为您正在加载的页面比您的 WebBrowser 控件的 MaxHeight 长?
-
如果我禁用了 VerticalScrollBar,我认为即使页面高度更长,它也不应该出现。
标签: c# html wpf iframe webbrowser-control