Quantcast
Channel: Infragistics Community
Viewing all articles
Browse latest Browse all 2374

Add Windows 8 Aero Theme Support to your WPF Custom Control

$
0
0

If you write your own WPF custom controls, you are probably aware of how to go about adding theming support for the various Windows themes.  One of the more popular themes introduced in Windows Vista, and continued over to Windows 7, was the Aero theme.  This is all fine and dandy if your WPF custom controls are used in applications that only run on Vista and Windows 7, but what happens when you try to use them on Windows 8?  Well, I’ll tell you… no Aero theme will be applied.  Why?  The Aero theme was removed from Windows 8.  That’s right, no more drop shadows, and no more glass window chrome effects.

So what now?  Luckily, there is still a way to provide theming support for Windows 8.  It’s just difficult to figure out because it is not documented yet.  Go figure!  I am sure you are aware of the naming convention for themes.  Just in case you forgot it goes a little something like this.

Themes\"Theme Name"."Theme Color".xaml

“Themes” is of course the subfolder where your theme files are located within your control assembly.  “Theme Name” refers to the name of the theme.  For example; Aero.  “Theme Color” is the color of the theme. For example; NormalColor.  Here is a list of supported themes.

File NameWindows Theme
Classic.xamlClassic Windows 9x/2000 look on Windows XP
Luna.NormalColor.xamlDefault blue theme on Windows XP
Luna.Homestead.xamlOlive theme on Windows XP
Luna.Metallic.xamlSilver theme on Windows XP
Royal.NormalColor.xamlDefault theme on Windows XP Media Center Edition
Aero.NormalColor.xamlDefault theme on Windows Vista/Windows 7

That’s good to know, but what about Windows 8?  Excellent question!  In order to provide theming support for Windows 8 you need to name your theme file as follows.

Aero2.NormalColor.xaml

You can see it here in the solution explorer.

Aero2.NormalColor.xaml theme file for Windows 8

Wait… That’s it?  Just add a number “2” after “Aero”?  Yup, that’s it.  Honestly, I’m not really sure why they decided on Aero2.NormalColor.xaml.  The fact that the Aero theme is gone from Windows 8 makes me think that there should have been a new name all together.  My guess is that this all occurred during the messy “Metro” naming fiasco, so they just decided to choose something.  To Microsoft’s credit, Most of the Aero features are still in Windows 8.  Such as the windows pinning, shake, and peek features.  Really, the only thing that was really dropped were the visual aspects (glass window chrome and drop shadows) in favor of their new Microsoft Design Style (aka Metro).

One more question Brian.  What happens if Windows 8 doesn’t find this new Aero2.NormalColor.xaml file?  The answer to that is simple.  It next looks for a Classic.xaml, and if it can’t find that theme file, then falls back to the Generic.xaml.

I hope that clears up some confusion on adding support for Windows 8 to your custom control library.  Feel free contact me on my blog, connect with me on Twitter (@brianlagunas), or leave a comment below for any questions or comments you may have.


Viewing all articles
Browse latest Browse all 2374

Trending Articles