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:
Let’s take Aero folder… 🙂
Inside you can find the following folder
126.96.36.199__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=188.8.131.52, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL; component/themes/aero.normalcolor.xaml" /> </Application.Resources>
So what do we set here… PresentationFramework.Aero is the source for resources. Version is taken by you from the folder "184.108.40.206__31bf3856ad364e35" in my case it is "220.127.116.11". Culture is neutral. Public key token is also taken from the folder "18.104.22.168__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.
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.