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.
- Create a new WPF application;
- Open the App.xaml file;
- Within the Application.Resources section add the following key:
<ResourceDictionary Source=”/PresentationFramework.Aero,Version=22.214.171.124, 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: