WPF使用的Windows窗体没有默认的系统设计

时间:2022-09-19 15:52:16

For instance if a "System.Windows.Forms.MessageBox" is created in a WPF application the design of buttons and such does not have default system appearance. Is there any solution to this?

例如,如果在WPF应用程序中创建“System.Windows.Forms.MessageBox”,则按钮等的设计没有默认的系统外观。这有什么解决方案吗?

1 个解决方案

#1


0  

I have found a solution. First add following first in main:

我找到了解决方案。首先在main中添加以下内容:

System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

Then add manifest file and uncomment followning lines:

然后添加清单文件并取消注释后续行:

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
   <dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="*"
          publicKeyToken="6595b64144ccf1df"
          language="*"
        />
    </dependentAssembly>
  </dependency>

Now the Windows Forms used in the WPF application should have default appearance.

现在,WPF应用程序中使用的Windows窗体应具有默认外观。

#1


0  

I have found a solution. First add following first in main:

我找到了解决方案。首先在main中添加以下内容:

System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

Then add manifest file and uncomment followning lines:

然后添加清单文件并取消注释后续行:

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
   <dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="*"
          publicKeyToken="6595b64144ccf1df"
          language="*"
        />
    </dependentAssembly>
  </dependency>

Now the Windows Forms used in the WPF application should have default appearance.

现在,WPF应用程序中使用的Windows窗体应具有默认外观。