帮助:更改WPF应用程序清单? [英] Help: Change WPF application manifest?
问题描述
我向Microsoft发表了评论 WPF中的框未启用VisualStyle.
Joe Castro在此处发布了一种解决方法,我真的不知道该如何实现,任何人都可以帮忙吗?
这是他的回复:
出于应用程序兼容性的原因,默认情况下,应用程序不使用系统通用控件的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>
我前一段时间在我的博客上写过它:
这些帖子描述了问题和解决方法: http://www.nbdtech.com/blog/archive/2008/06/08/Will-Setting-a-Manifest-Solve-My-WPF- Message-Box-Style.aspx
您正在寻找的帖子: http://www.nbdtech.com/blog/archive/2008/07/15/Vista-style-open-并在不使用using.aspx的情况下使用WPF保存对话
I posted a comment to Microsoft that the Dialog Boxes in WPF are not VisualStyle enabled.
Joe Castro posted a workaround there which I don't really understand how to achieve, can anyone help?
Here is he's response:
For app compat reasons applications don't by default use v6 of the system common controls (available since XP). This doesn't really apply to WPF, but you also only see it in a few situations when using the native controls so it's not as prevalent as WinForms where their APIs are just wrapping the standard controls.
To fix this in WPF you need to explicitly opt-in to v6 comctl32 by specifying it in a manifest in your exe. This has to be done on the exe, so WPF can't do it as part of their DLLs. EnableVisualStyles does this at runtime but this way is generally better.
E.g., something like:
<?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>
I wrote about it on my blog some time ago:
Those posts describe the problem and the solution: 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
This post is what you are looking for : http://www.nbdtech.com/blog/archive/2008/06/16/The-Application-Manifest-Needed-for-XP-and-Vista-Style-File.aspx
And this talks about how to get the Vista style for file open and save dialogs: http://www.nbdtech.com/blog/archive/2008/07/15/Vista-style-open-and-save-dialogs-with-WPF-without-using.aspx
这篇关于帮助:更改WPF应用程序清单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!