Getting Aero theme with WPF on Windows XP


For those guys who like Aero very much but cannot migrate their projects at a moment there’s quite a good news 🙂 You don’t have to buy third party controls styled like Aero or Luna or Royale theme today because there’s some dirty tricks to enable that stuff in your application.

When you install .net 3.0 framework you automatically get some candies into your GAC that might help you styling your applications. Assuming you have the most common system path try to navigate the "C:WindowsassemblyGAC_MSIL" folder.

There you can find several folders starting from "PresentationFramework" plus the name of the theme. At my laptop I now see following:

PresentationFramework.Aero

PresentationFramework.Classic

PresentationFramework.Luna

PresentationFramework.Royale

Let’s take Aero folder… 🙂

Inside you can find the following folder

3.0.0.0__31bf3856ad364e35  (Note that the name of the folder can be different from mentioned)

It contains the assembly called "PresentationFramework.Aero.dll"

Fine, that’s enough information for us to bind the theme to our application. How should we do that?

Open your "App.xaml" and move to the resources section. All you need to do is to add one single line defining the resource dictionary like in the sample below

<Application x:Class="Vista.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="Window1.xaml">
<Application.Resources>
        <ResourceDictionary 
            Source="/PresentationFramework.Aero, 
            Version=3.0.0.0, 
            Culture=neutral, 
            PublicKeyToken=31bf3856ad364e35, 
            ProcessorArchitecture=MSIL;
            component/themes/aero.normalcolor.xaml" />
    </Application.Resources>

</Application>

So what do we set here… PresentationFramework.Aero is the source for resources. Version is taken by you from the folder "3.0.0.0__31bf3856ad364e35" in my case it is "3.0.0.0". Culture is neutral. Public key token is also taken from the folder "3.0.0.0__31bf3856ad364e35" and has the value "31bf3856ad364e35". The rest should be typed as it is given in the sample.

Now place some controls on the canvas and you can immediately see the changes in the Visual Studio WPF designer (I used VS 2008 TS beta 2 for preparing the sample). This is also a perfect feature of Visual Studio :). Of course you won’t get the glass effect for the whole window, but at least all your controls are styled well.

I’ve prepared one small screenshot for you to get the idea.

aero with windows xp

And don’t forget that you are running Windows XP 😉

Guess I must leave you playing with this stuff for yourselves. There are also other themes mentioned so you may play with them a bit.

Have a nice coding.

Source code for the article

Advertisements

2 thoughts on “Getting Aero theme with WPF on Windows XP

  1. Hi,the article is very helpful, but i was wondering is there way to render the title bar using aero theme???Thanks

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