Help: Change WPF application manifest?

最后都变了- 提交于 2020-01-04 09:18:10

问题


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>

回答1:


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




回答2:


In Visual Basic, the project properties are structured a little differently. If you find this question and you're in VB in VS2010, follow these instructions to generate an app.manifest file.

  1. To create an app.manifest file, go to your project, and select properties. Then click on View Window Settings, under the Application tab.
  2. This should generate and open the app.manifest file, which is saved in your My Project Folder

Further Reading: WPF MessageBox window style



来源:https://stackoverflow.com/questions/1656219/help-change-wpf-application-manifest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!