Posted by: Cirilo Meggiolaro | 02/28/2009

Tip of the day #137 – Applying Windows Vista themes on WPF applications running on Windows XP

Today’s tip is about the famous Windows Vista themes. Did you know it’s possible to enforce a Windows Presentation Foundation (WPF) application to use the Windows Vista themes even when running the application on computers with Windows XP operation system? Yes, it is possible.

How to…

  • Create a new WPF application;
  • Open the App.xaml file;
  • Within the Application.Resources section add the following key:

<ResourceDictionary Source=”/PresentationFramework.Aero,Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml” />

The key contains a reference to the PresentationFramework.Aero.dll available under the Global Assembly Cache (c:\windows\assembly). Each Windows Vista theme has its own assembly such as Aero, Classic, Luna and Royale. You have to know the theme you want to use and the respective version and public key token for the assembly.

Add some controls to the Window1.xaml file. You’ll be able to see the Windows Vista style applied to all controls as shown on the following picture:

Picture 1 - WPF application controls with the Windows Vista Aero theme running on Windows XP.

Picture 1 - WPF application controls with the Windows Vista Aero theme running on Windows XP.

Picture 2 - WPF application controls with the Windows Vista Luna theme running on Windows XP.

Picture 2 - WPF application controls with the Windows Vista Luna theme running on Windows XP.

Advertisements

Responses

  1. How about the title bar and borders? It’s possible to make it looks like Vista in XP?

  2. Hi Daniel,

    Unfortunately using this approach you’ll be able to set only the controls. You may use a different approach for that. It’s not pretty straightforward but it is possible. I am going to post this week an example about how to handle that.

    Thanks by the comment!

    Stay tuned!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: