[英]Windows 7 theme for WPF?
有没有办法让 WPF 应用程序看起来像在 Windows 7 上运行,即使它在 XP 上运行? 我正在寻找某种我可以粘贴的主题。我知道 Codeplex ( https://archive.codeplex.com/?p=wpfthemes ) 上的主题项目,但它缺乏对DataGrid
支持,其中是我非常需要的东西。 我在想 Windows 7 主题可能只是一个简单的端口,或者已经存在于某个文件中。
更新
使用@Lars Truijens 的想法,我能够在 Windows 7 中查找主要控件,但不幸的是它不适用于我需要的 WPF Toolkit DataGrid
控件。
带有 Aero 主题的DataGrid
看起来像这样
DataGrid
应该是这样的
因此,如果有人有任何想法,我仍在寻找解决此问题的方法。 也许有人已经构建了涵盖 WPF 工具包控件的 Aero 主题扩展? 同样,非常感谢您拥有的任何信息。
更新 2 - DataGrid 问题解决了!
要使 Aero 主题与 DataGrid 或任何其他 WPF Toolkit 控件一起使用,您只需添加第二个 Aero 字典,因此您的 App.xaml 现在应如下所示。
<Application.Resources>
...
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml" />
<ResourceDictionary
Source="pack://application:,,,/WPFToolkit;component/Themes/Aero.NormalColor.xaml" />
...
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
另外,我建议关闭DataGrid
控件中的网格线(因为它们看起来很糟糕):
<DataGrid GridLinesVisibility="None" ...>
WPF 在所有 Windows 版本上都带有标准的 Windows 主题。 例如,您可以通过以下步骤在 Windows XP 上使用 Aero 主题(Vista 和 Windows 7 使用):
由此
<Application.Resources>
<!-- Your stuff here -->
</Application.Resources>
对此
<Application.Resources>
<ResourceDictionary>
<!-- Put your stuff here instead -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
来源: http : //mrpmorris.blogspot.com/2008/05/using-vista-aero-theme-in-xp-wpf-apps.html
下面的其他选择。 请务必根据需要将相应的程序集添加到应用程序的参考列表中。
<ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Classic;component/themes/Classic.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Royale;component/themes/Royale.NormalColor.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Luna.Homestead;component/themes/Luna.Homestead.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Luna.Metallic;component/themes/Luna.Metallic.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Zune;component/themes/Zune.NormalColor.xaml"/>
Lars 的回答和 DanM 的更新的一项补充:
部署时,必须在安装目录中添加aero Dll。
您可以通过转到添加到引用中的 PresentationFramework.Aero 的属性并设置CopyLocal=True
。 然后,您必须使用正在使用的任何部署工具(我喜欢 WIX...)并将其添加到已部署文件列表中。
转到您的解决方案/项目属性,在“参考”下,您将能够添加对 PresentationFramework.Aero 的引用...将其应用到您的代码中,它应该可以很好地工作
希望我的回答对你有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.