RSS

Getting Aero theme with WPF on Windows XP

02 Nov

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

About these ads
 
2 Comments

Posted by on November 2, 2007 in .NET WPF

 

2 Responses to Getting Aero theme with WPF on Windows XP

  1. Unknown

    June 9, 2008 at 08:32

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

     
  2. Daniyal

    February 17, 2011 at 18:26

    Hi.
    I just wanted to say, if somebody has a problem with the ResourceDictionary’s Source attribute parsing at runtime, you can try to use “pack://application:,,,/” prefix like this:

    in my case it is WPF 4.0 and it worked for me. For more info about the Pack in URIs see:
    http://msdn.microsoft.com/en-us/library/aa970069.aspx#Resource_File_Pack_URIs___Local_Assembly

     

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 )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 71 other followers

%d bloggers like this: