C# WebBrowser:画圆圈?

C# WebBrowser: draw circle?

我正在编写一个简单的可视化应用程序,但遇到一个小问题: webBrowser.Version returns Build: 9600 Major: 11 尽管我不能使用现代 CSS3 功能来画圆。下面是 HTML 代码和我得到的输出。我尝试了 google 上的各种方法,但似乎没有任何效果。删除了不必要的代码,只留下在 webBrowser 中不起作用的部分。

哦,顺便说一句,它在独立 IE 中打开时有效。也试过`border-radius: 50%

here is image of what I get

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Main Window</title>
    <style>
        .circle {
            border-radius: 10px;
            width: 20px;
            height: 20px;
            background: blue;
        }
    </style>
</head>
<body>
    <div class="circle"></div>
</body>
</html>

我认为 WebBrowser 卡在 IE7 或 IE8 上。几年前我尝试了其中一些技巧来更改其版本:

https://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version

还有Use latest version of Internet Explorer in the webbrowser control

这是因为 WebBrowser class 模拟 IE,因此会有一个 HKEY 设置模拟中使用的 IE 版本。

以下是一些建议或备选方案。

元标记

<meta http-equiv="X-UA-Compatible" content="IE=10" />

将以上内容添加到您的HTML,它会尝试强制浏览器在 IE10 中显示内容。


HKEY 在机器上更改

找到下面的HKEY

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

然后像这样更改或添加您的应用程序的值

FEATURE_BROWSER_EMULATION "myAppName.exe"=10000

HKEY 代码更改

要执行与上面相同的操作,但在代码中,请使用以下内容:

RegistryKey registrybrowser = Registry.LocalMachine.OpenSubKey
           (@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
        registrybrowser.SetValue("myAppName.exe", 10000, RegistryValueKind.DWord);