Windows 7的主题为WPF? [英] Windows 7 theme for WPF?

查看:222
本文介绍了Windows 7的主题为WPF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法让一个WPF应用程序看起来像它在Windows 7上运行,即使它在XP上运行?我正在寻找一些主题我可以粘贴我知道在codePLEX主题项目(的 HTTP://www.$c$cplex.com/wpfthemes ),但它缺乏对的DataGrid ,这是我极为支持需要。我想也许在Windows 7主题将只是一个简单的端口,或存在于一些文件的地方了。你有(哪怕是个坏消息)的任何信息将是非常美联社preciated。

更新

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

的DataGrid 看起来是这个Aero主题

删除死ImageShack链接

的DataGrid 应该的这个样子

删除死ImageShack链接

所以,我还在寻找一个解决这个问题,如果任何人有任何的想法。也许有人已经建立了一个扩展的Aero主题,涵盖了WPF工具包控件?同样,你有任何的信息是非常AP preciated。

更新2 - 问题解决了

要获得Aero主题与WPF工具包的控制工作,你只需要添加第二个航空词典,让你的App.xaml中,现在应该是这样的。

 < Application.Resources>
    ...
    <的ResourceDictionary>
        < ResourceDictionary.MergedDictionaries>
            <的ResourceDictionary
                来源=/ presentationFramework.Aero;组件/主题/ Aero.NormalColor.xaml/>
            <的ResourceDictionary
                来源=包://应用:,,, / WPFToolkit;组件/主题/ Aero.NormalColor.xaml/>
            ...
        < /ResourceDictionary.MergedDictionaries>
    < / ResourceDictionary中>
< /Application.Resources>
 

另外,我建议在的DataGrid 控制旋转网格线关闭(因为他们看的可怕的):

 <数据网格GridLinesVisibility =无...>
 

解决方案

WPF自带的标准的Windows主题,在所有的Windows版本。例如,你可以有Aero主题(其中Vista和Windows 7中使用)的Windows XP以下步骤:

  1. 添加presentationFramework.Aero到应用程序的引用列表作为要求
  2. 编辑您的App.xaml

 < Application.Resources>
  <  - !你的东西在这里 - >
< /Application.Resources>
 

 < Application.Resources>
  <的ResourceDictionary>
    <! - 把你的东西,而不是在这里 - >

    < ResourceDictionary.MergedDictionaries>
      < ResourceDictionary中源=/ presentationFramework.Aero;组件/主题/ Aero.NormalColor.xaml/>
    < /ResourceDictionary.MergedDictionaries>
  < / ResourceDictionary中>
< /Application.Resources>
 

来源: <一个href="http://mrpmorris.blogspot.com/2008/05/using-vista-aero-theme-in-xp-wpf-apps.html">http://mrpmorris.blogspot.com/2008/05/using-vista-aero-theme-in-xp-wpf-apps.html

下面其他的替代品。请务必将相应的组件添加到应用程序的参考列表作为要求。

 &LT; ResourceDictionary中源=/ presentationFramework.Aero;组件/主题/ Aero.NormalColor.xaml/&GT;
&LT; ResourceDictionary中源=/ presentationFramework.Classic;组件/主题/ Classic.xaml/&GT;
&LT; ResourceDictionary中源=/ presentationFramework.Royale;组件/主题/ Royale.NormalColor.xaml/&GT;
&LT; ResourceDictionary中源=/ presentationFramework.Luna.Homestead;组件/主题/ Luna.Homestead.xaml/&GT;
&LT; ResourceDictionary中源=/ presentationFramework.Luna.Metallic;组件/主题/ Luna.Metallic.xaml/&GT;
&LT; ResourceDictionary中源=/ presentationFramework.Zune;组件/主题/ Zune.NormalColor.xaml/&GT;
 

Is there any way to make a WPF app look like it's running on Windows 7 even if it's running on XP? I'm looking for some kind of theme I can just paste in. I'm aware of the themes project on Codeplex (http://www.codeplex.com/wpfthemes), but it lacks support for DataGrid, which is something I critically need. I was thinking maybe the Windows 7 theme would just be an easy port, or exists in some file somewhere already. Any information you have (even if it's bad news) would be much appreciated.

Update

Using @Lars Truijens idea, I was able to get the Windows 7 look for the major controls, but unfortunately it did not work for the WPF Toolkit DataGrid control, which I need.

DataGrid looks like this with Aero theme

removed dead ImageShack link

DataGrid should look like this

removed dead ImageShack link

So, I'm still looking for a solution to this problem if anyone has any ideas. Maybe someone has built an extension to the Aero theme that covers the WPF toolkit controls? Again, any information you have is much appreciated.

Update 2 - Problem solved!

To get the Aero theme to work with WPF Toolkit controls, you just need to add a second Aero dictionary, so your App.xaml should now look like this.

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

Also, I would recommend turning the gridlines off in your DataGrid controls (because they look horrible):

<DataGrid  GridLinesVisibility="None" ...>

解决方案

WPF comes with the standard Windows themes on all Windows versions. For example, you can have the Aero theme (which Vista and Windows 7 use) on Windows XP with the following steps:

  1. Add PresentationFramework.Aero to your application's references list as a requires
  2. Edit your App.xaml

from this

<Application.Resources>
  <!-- Your stuff here -->
</Application.Resources>

to this

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

    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
    </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</Application.Resources> 

Source: http://mrpmorris.blogspot.com/2008/05/using-vista-aero-theme-in-xp-wpf-apps.html

Other alternatives below. Be sure to add the corresponding assembly to your application's reference list as a requires.

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

这篇关于Windows 7的主题为WPF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆