将WPF webbrowser控件设置为使用IE10模式

Jib*_*hew 14 wpf webbrowser-control wpf-controls

如何设置WPF webbrowser控件以在iE10模式下呈现页面或在机器上安装更高版本.默认情况下,如果我在OS> Windows 7的任何机器上创建.net 4或.net 4.5应用程序,它只会在IE7模式下呈现html页面.(如果我错了,请更正)如果在目标机器上安装IE10,如何启用应用程序以IE10模式呈现html页面?任何帮助

xr2*_*0xr 20

如果您不想修改注册表并控制网页,则可以使用

<meta http-equiv="X-UA-Compatible" content="IE=10">
Run Code Online (Sandbox Code Playgroud)

标签在文件的头部.我认为必须首先或紧接着<title>才能工作.

  • @Luke设置内容="IE =边缘". (2认同)

小智 7

您可以使用此处所述的注册表:

http://msdn.microsoft.com/en-us/library/ie/ee330730%28v=vs.85%29.aspx

编辑:为了更好的解释你也可以阅读这个答案 IE9 WebBrowser控件是否支持所有IE9的功能,包括SVG?


Men*_*tor 5

对于WPF网页浏览器控件使用IE11模式需要,例如在主窗口的构造函数中,添加如下代码:

var pricipal = new System.Security.Principal.WindowsPrincipal(
  System.Security.Principal.WindowsIdentity.GetCurrent());
if(pricipal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)) {
    RegistryKey registrybrowser = Registry.LocalMachine.OpenSubKey
        (@"Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
    string myProgramName = Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);
    var currentValue = registrybrowser.GetValue(myProgramName);
    if (currentValue == null || (int)currentValue != 0x00002af9)
        registrybrowser.SetValue(myProgramName, 0x00002af9, RegistryValueKind.DWord);
}
else
    this.Title += " ( ?????? ??? ????????? ? ??????? ?????? )";
Run Code Online (Sandbox Code Playgroud)

如果你想看到 WPF webbrowser 控件在从 Visual Studio 运行时在 DEBUG 模式下使用 IE11 模式,你需要在注册表中添加所有程序“*”。这可以通过以下代码完成:

var pricipal = new System.Security.Principal.WindowsPrincipal(
    System.Security.Principal.WindowsIdentity.GetCurrent());
if (pricipal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)) {
    RegistryKey registrybrowser = Registry.LocalMachine.OpenSubKey
    (@"Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
    var currentValue = registrybrowser.GetValue("*");
    if (currentValue == null || (int)currentValue != 0x00002af9)
        registrybrowser.SetValue("*", 0x00002af9, RegistryValueKind.DWord);
}
else
    this.Title += " ( ?????? ??? ????????? ? ??????? ?????? )";
Run Code Online (Sandbox Code Playgroud)

检查 Windows 10 和 Visual Studio 2015。

备注:其他版本的 Internet Explorer 代码,请参见此处https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx#browser_emulation