gpt4 book ai didi

.net - WPF 的 Windows 7 主题?

转载 作者:可可西里 更新时间:2023-11-01 11:59:15 26 4
gpt4 key购买 nike

有什么方法可以使 WPF 应用看起来像是在 Windows 7 上运行,即使它在 XP 上运行也是如此?我正在寻找某种我可以粘贴的主题。我知道 Codeplex ( https://archive.codeplex.com/?p=wpfthemes ) 上的主题项目,但它缺乏对 DataGrid 的支持,这是我批判的需要。我在想也许 Windows 7 主题只是一个简单的端口,或者已经存在于某个文件中的某个地方。


更新

使用@Lars Truijens 的想法,我能够获得 Windows 7 的主要控件外观,但不幸的是它不适用于我需要的 WPF 工具包 DataGrid 控件。

DataGrid 使用 Aero 主题看起来像这样

Windows XP-look DataGrid

DataGrid 应该看起来像这样

Windows 7-look DataGrid

因此,如果有人有任何想法,我仍在寻找解决此问题的方法。也许有人构建了涵盖 WPF 工具包控件的 Aero 主题扩展?同样,非常感谢您提供的任何信息。


更新 2 - DataGrid 问题已解决!

要使 Aero 主题与 DataGrid 或任何其他 WPF 工具包控件一起使用,您只需添加第二个 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 使用):

  1. 根据需要将 PresentationFramework.Aero 添加到应用程序的引用列表中
  2. 编辑您的 App.xaml

由此

<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"/>

关于.net - WPF 的 Windows 7 主题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2075720/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com