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

将WPF webbrowser控件设置为使用IE10模式,wpf,wpf-controls,webbrowser-control,Wpf,Wpf Controls,Webbrowser Control,如何设置WPF webbrowser控件以iE10模式或计算机上安装的更高版本呈现页面。 默认情况下,如果我在OS>Windows7的任何机器上创建.NET4或.NET4.5应用程序,它只在IE7模式下呈现html页面。(如果我错了,请更正) 如果目标机器上安装了IE10,如何使应用程序以IE10模式呈现html页面?任何帮助您可以使用注册表,如下所述: 编辑: 为了更好的解释,你也可以阅读这个答案 对于WPF webbrowser控件,使用IE11模式需要,例如,在主窗口的构造函数中,添加以

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

您可以使用注册表,如下所述:

编辑: 为了更好的解释,你也可以阅读这个答案
对于WPF webbrowser控件,使用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 += " ( Первый раз запускать с правами админа )";
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 += " ( Первый раз запускать с правами админа )";
如果希望在从visual studio运行时看到WPF webbrowser控件在调试模式下使用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 += " ( Первый раз запускать с правами админа )";
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 += " ( Первый раз запускать с правами админа )";
已检查windows 10和visual studio 2015


备注:为internet explorer的其他版本编码,请参见此处

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

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


在文档的头部添加标记。我相信它必须是第一个或紧跟在
之后才能工作。

如果我们进行注册表编辑,那么我也必须在目标机器上进行同样的操作,对吗?另外,如果通过更改注册表将浏览器模式更改为IE9/10,这是否仅影响应用程序内部的浏览器控件,或者影响整个IE应用程序>,则必须在目标计算机上执行相同的操作。它只影响应用程序中的浏览器,因为您必须在注册表中设置应用程序的名称。我按照中的说明进行操作,并将“获取文档模式”设置为5。你知道为什么吗。但是我的注册表显示IETest.exe的值为270f(IE9的)。IETest.exe的位置是否有任何影响如果您的wpf应用程序是32位的,您必须使用Wow6432Node,如果是64位的,则必须使用Wow6432Node。我的应用程序针对任何平台模式,我尝试添加32位和64位,但在所有情况下它都返回5谢谢您的代码,这是在W10中唯一有效的代码。但是,您不需要添加注册表所有程序以在调试模式下工作。您可以简单地注册为vshost名称,注册方式与注册程序名相同。字符串appName=System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutionGassembly().Location);字符串appNameExe=appName+“.exe”;字符串appVSNameExe=appName+“.vshost..exe”;然后将当前值应用于appNameExe和appVSNameExe,它将在不强制*all的情况下对两者都有效这是正确的答案。没有必要编辑注册表,它对我来说非常好。我可以拥有多个吗?假设用户在Windows 7上运行,并且我设置了
IE=11
,Windows 7是否以IE10模式呈现它?@Luke set content=“IE=edge”。已确认。如果控制HTML控件中加载的内容,这是最好的方法。没有可能影响其他应用程序的注册表更改。谢谢