I posted a comment to Microsoft WPF中的对话框未启用VisualStyle。
Joe Castro在那里发布了一个解决方法,我真的不明白如何实现,任何人都可以帮忙吗?
以下是他的回复:
对于app compat原因,应用程序默认情况下不使用系统通用控件的v6(自XP以来可用)。这并不适用于WPF,但是在使用本机控件时,您也只能在少数情况下看到它,因此它不像WinForms那样普遍,它们的API只包含标准控件。
要在WPF中修复此问题,您需要通过在exe中的清单中指定它来显式选择加入v6 comctl32。这必须在exe上完成,因此WPF不能将其作为DLL的一部分。 EnableVisualStyles在运行时执行此操作,但这种方式通常更好。
,例如:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>MyExe.exe</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
</assembly>
答案 0 :(得分:4)
我前段时间在博客上写过这篇文章:
这些帖子描述了问题和解决方案:http://www.nbdtech.com/blog/archive/2008/05/28/Why-am-I-Getting-Old-Style-File-Dialogs-and-Message.aspx,http://www.nbdtech.com/blog/archive/2008/06/08/Will-Setting-a-Manifest-Solve-My-WPF-Message-Box-Style.aspx
这里讨论了如何让文件打开并保存对话框的Vista风格:http://www.nbdtech.com/blog/archive/2008/07/15/Vista-style-open-and-save-dialogs-with-WPF-without-using.aspx
答案 1 :(得分:1)
在Visual Basic中,项目属性的结构略有不同。如果您发现此问题并且您在VS2010中使用VB,请按照以下说明生成 app.manifest 文件。
进一步阅读: WPF MessageBox window style