帮助:更改WPF应用程序清单?
-
11-09-2019 - |
题
我向微软发表了评论 WPF中的对话框不启用Visual Ststyle。
乔·卡斯特罗(Joe Castro)在那里发布了一个解决方法,我真的不明白该如何实现,有人可以提供帮助吗?
这是他的回应:
出于应用程序兼容原因,默认情况下,应用程序不使用系统通用控件的V6(自XP以来可用)。这并不真正适用于WPF,但是您也只能在使用本机控件时在某些情况下看到它,因此它不像其API仅包装标准控件的Winform那样普遍。
要在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>
解决方案
我一段时间以前在博客上写了有关它的文章:
这些帖子描述了问题和解决方案: http://www.nbdtech.com/blog/archive/2008/05/28/why-am-i-getting of-style-style-file-dialogs-and-message.aspx , http://www.nbdtech.com/blog/archive/2008/06/08/will-setting-a-manifest-solve-solve-my-wpf-message-box-box-style.aspx
这篇文章是您正在寻找的内容: http://www.nbdtech.com/blog/archive/2008/06/16/the-application-manifest-needed-for-xp-and-vista-style-file.aspx
这谈到了如何使Vista样式打开并保存对话框: http://www.nbdtech.com/blog/archive/2008/07/15/vista-style-open-and-and-save-dialogs-with-with-with-with-wpf-without-using.aspx
其他提示
在Visual Basic中,项目属性的结构略有不同。如果您发现这个问题并且您在VS2010中的VB中,请按照以下说明生成一个 app.manifest 文件。
- 创建一个 app.manifest 文件,转到您的项目,然后选择属性。然后单击 查看窗口设置, , 在下面 应用 标签。
- 这应该产生并打开 app.manifest 文件,保存在您的 我的项目文件夹
进一步阅读: WPF消息框窗口样式