Saturday, March 21, 2009

Vista Theme in WPF

In this short post i will give you idea of how you can apply window vista theme in your WPF applications. I will try to explain you which are the point where theme is not applied on your applications. But i thing most of the control in you application will have window vista theme using this technique. Here is the sample image of the application which i have created for this post and you will download this sample code, and link is given below. You can see that vista theme is applied on most of the controls and the application look like vista application.

To achieve the above result in your application what you have to do is add the following line of code in your Application.Resources section of your app.xaml file and the theme will be applied to the whole application

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

Using the above technique you can following theme which you can use in your application.
  • PresentationFramework.Aero
  • PresentationFramework.Classic
  • PresentationFramework.Luna
  • PresentationFramework.Royale
I have used the first one for my application you can use any of other in you application.The limitation of this technique is that it don't change the look of container form. You can see it still looks like a window classic form. And also the MessageBox and the if you download and look at the combo Box item mouse over of the item it still looks window classic theme.You can download the source code from here

All and any comments / bugs / suggestions are welcomed!

2 comments:

aj said...

is it possible to change the theme at runtime?

awaisj said...

Asim, can you please provide an article on WPF for the beginners?