WPF 应用程序中的 WinForms 对话框:控件看起来像 .NET 2.0 [英] WinForms Dialogs in WPF Application: Controls look like .NET 2.0

查看:28
本文介绍了WPF 应用程序中的 WinForms 对话框:控件看起来像 .NET 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WinForms 应用程序并开始将其转换为 WPF.为了减少工作量,我的想法是让旧的对话框窗口成为 WinForms.在 VS2010-designer 中,对话框看起来很正常(使用 .NET 3.5/4.0 控件)但是如果我运行我的程序,所有 WinForms 控件都会变成旧样式,看起来像 .NET 2.0(我想你知道我的意思,那个灰色所有控件的斜角样式...)

I have an WinForms application and started to convert it into WPF. To have less work, my idea was to let the old dialog windows be WinForms. In the VS2010-designer the dialogs looks normal (with .NET 3.5/4.0 controls) but if I run my program all WinForms controls change into an old style and it looks like .NET 2.0 (I think you know what I mean, that grey bevel style for all controls...)

那里发生了什么?有什么办法可以解决吗?

What happens there? Any ways to fix that?

推荐答案

您必须调用 System.Windows.Forms.Application.EnableVisualStyles() 来启用 Windows 窗体的系统样式.WinForms 项目模板默认包含该调用;WPF 模板缺少它,因为 WPF 控件不需要它.

You have to call System.Windows.Forms.Application.EnableVisualStyles() to enable the system style for Windows Forms. The WinForms project template contain that call by default; the WPF template is missing it as WPF controls do not need it.

这篇关于WPF 应用程序中的 WinForms 对话框:控件看起来像 .NET 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆