WPF的Windows 7主题?

dev*_*xer 41 .net windows wpf themes wpftoolkit

是否有任何方法可以使WPF应用看起来像在Windows 7上运行,即使它在XP上运行?我正在寻找一些我可以粘贴的主题.我知道Codeplex上的主题项目(http://www.codeplex.com/wpfthemes),但它缺乏支持DataGrid,这是我批判性的需要.我想也许Windows 7主题可能只是一个简单的端口,或者已存在于某个文件中.您所拥有的任何信息(即使是坏消息)都将非常感激.

更新

使用@Lars Truijens的想法,我能够获得主要控件的Windows 7外观,但遗憾的是它不能用于DataGrid我需要的WPF Toolkit 控件.

DataGrid Aero主题看起来像这样

Windows XP外观DataGrid

DataGrid 应该是这样的

Windows 7外观DataGrid

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

更新2 - 问题解决了!

要使Aero主题与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>
Run Code Online (Sandbox Code Playgroud)

另外,我建议你在DataGrid控件中关闭网格线(因为它们看起来很糟糕):

<DataGrid GridLinesVisibility="None" ...>
Run Code Online (Sandbox Code Playgroud)

Lar*_*ens 53

WPF在所有Windows版本上都带有标准的Windows主题.例如,您可以使用以下步骤在Windows XP上安装Aero主题(Vista和Windows 7使用):

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

由此

<Application.Resources>
  <!-- Your stuff here -->
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)

对此

<Application.Resources>
  <ResourceDictionary>
    <!-- Put your stuff here instead -->

    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
    </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</Application.Resources> 
Run Code Online (Sandbox Code Playgroud)

资料来源: 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"/>
Run Code Online (Sandbox Code Playgroud)

  • 您应该将动态引用转换为完整引用,否则您需要部署PresentationFramework.aero.请参阅我的回答:http://stackoverflow.com/questions/8175410/wpf-when-using-presentationframework-aero-do-i-need-to-set-copy-local-to-tru/8185946#8185946 (3认同)