【问题标题】:WPF WebBrowser Control - position:fixed Element jumps while scrolling (Windows 8)WPF WebBrowser Control - 位置:固定元素在滚动时跳转(Windows 8)
【发布时间】:2013-06-20 09:08:24
【问题描述】:

我们使用 WPF WebBrowser 控件来显示嵌入页面。在 Windows 8 上,我们观察到具有 css position:fixed 的元素在滚动时出现奇怪的跳跃行为。

同一页面在 Windows 8 上的 IE10(还有 FF、Chrome)和 Windows 7 上的 WPF WebBrowser 控件中运行良好。

以前有没有人见过这种行为并知道如何解决跳跃动作?

与开发机器上的 .NET 版本 4 相比,测试机器上使用的 .NET 版本 4.5(Win 8 的 Surface)是否可能是问题?

开发环境:

  • Windows 7
  • Microsoft Visual Studio 2010 版本 10.0.30319.1 RTMRel
  • Microsoft .NET Framework 版本 4

测试环境:

  • 表面
  • Windows 8
  • Microsoft .NET Framework 4.5 版

客户端 XAML:

<Window x:Class="EmbeddedBrowserTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <WebBrowser HorizontalAlignment="Stretch" Name="webBrowser" VerticalAlignment="Stretch" Grid.Row="1" />
    </Grid>
</Window>

演示页面 HTML:

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <title>minimal position fixed example</title>
    <style>
        body {
            margin: 0px
        }           
        .header{
            height: 60px;
            width: 960px;
            background-color: #cccccc;
            top: 0px;
            left: 0px;
            position: fixed;
            z-index: 10;
        }    
        .content{
            padding-top: 60px;
            height: 420px;
            width: 960px;
            background-color: lightsteelblue;
        }    
    </style>
</head>

<body>
    <div class="header">
        header
    </div>    
    <div class="content">
        content <br> 1 <br> 2 <br> 3 <br> 4 <br> 5 <br> 6 <br> 7 <br>
    </div>                
</body>

</html>

【问题讨论】:

  • 我相信WPF中的WebBrowser控件其实只是一个包装好的WinForms控件,不知这有关系吗?我想知道在 WinForms 项目中嵌入 Web 浏览器会发生什么?
  • 无法重现,抱歉(Windows 8,.Net 4.5,即 10)...

标签: c# css wpf windows-8 css-position


【解决方案1】:

如果加载到WebBrowser控件和独立IE浏览器中的相同网页的行为存在差异,通常可以通过实现WebBrowser Feature Control来解决问题。

一旦实现了功能控制,就可以验证&lt;!DOCTYPE html&gt; 是否被WebBrowser 观察到并且页面实际上是以HTML5 标准模式here's how 呈现的。

[更新]FEATURE_BROWSER_EMULATION 设置为9000 并且META 标记固定为&lt;meta http-equiv="X-UA-Compatible" content="IE=9" /&gt; 时,OP 的示例页面实际呈现正确(content=" IE9"not a valid value)。

【讨论】:

  • 感谢指向功能键的指针。当我们发布原始错误时,我们已经尝试过这些。不幸的是,它当时没有帮助。但是今天在应用适用于 Windows 8 的最新更新后,我们发现错误消失了。
【解决方案2】:

我们再次检查了一台同样运行 Windows 8 的新机器,错误消失了,经过一些检查,我们确定新机器安装了一些适用于 Windows 8 的新更新。我们去检查 Surface 上的更新,在应用所有更新后,错误似乎消失了。

无需任何重新编译或进一步设置,只需应用最新的 Win 8 更新即可修复错误。

现在滚动很流畅。相同的可执行文件没有变化,所以我想这毕竟是运行时库中的一些错误。

【讨论】:

  • 我将等待 5 小时直到 @mariusc 赏金结束,然后再接受我自己的答案,因为更新已修复它。
猜你喜欢
  • 2016-11-29
  • 1970-01-01
  • 2014-08-30
  • 1970-01-01
  • 1970-01-01
  • 2019-03-22
  • 1970-01-01
  • 2022-11-16
  • 2014-04-08
相关资源
最近更新 更多