首页 文章

WPF WebBrowser控件 - 位置:固定元素在滚动时跳转(Windows 8)

提问于
浏览
3

我们使用WPF WebBrowser控件来显示嵌入页面 . 在Windows 8上,我们观察到具有css位置的元素的奇怪跳跃行为:在滚动时固定 .

position:fixed is jumping when scrolling

同样的页面在Windows 8(也是FF,Chrome)上的IE10和Windows 7上的WPF WebBrowser控件中都能正常工作 .

有没有人见过这种行为,并知道跳跃运动的修复?

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

The Development Environment:

  • Windows 7

  • Microsoft Visual Studio 2010版本10.0.30319.1 RTMRel

  • Microsoft .NET Framework版本4

The Test Environment:

  • 表面

  • Windows 8

  • Microsoft .NET Framework 4.5版

Client 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>

Demo Page 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>

2 回答

  • 0

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

    Without any recompilation or further settings just by applying the latest Win 8 Updates the error is fixed.

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

  • 3

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

    一旦实现了功能控件,就有必要验证 WebBrowser 是否观察到 <!DOCTYPE html> ,并且页面实际上是以HTML5标准模式here's how呈现的 .

    [UPDATE]FEATURE_BROWSER_EMULATION设置为 9000META 标记固定为 <meta http-equiv="X-UA-Compatible" content="IE=9" /> (内容= "IE9"为not a valid value)时,OP的示例页面实际上正确呈现 .

相关问题