And again the result is disappointing, just look at our dialog and the Microsoft Paint open file dialog side by side (our dialog on top of MS Paint's) , see the difference in the icons and button styles?

So what just happened here? Why does our modern looking application displayed the old style message boxes and common dialogs?

The answer is that for Windows XP Microsoft created a whole new set of controls, the new controls supports advanced features like themes and are not compatible with the old set of controls (most controls didn’t change much from the version they were originally introduced – in order to be compatible with older software).

Originally the new set of controls were supposed to be completely new, with new names, new applications would use the new “UXButton” and old application would continue to use the old “Button”, but that didn’t work because a lot of application tried to mess with the internals of Microsoft’s software and when an external program tied to find a button inside Explorer and did find it - it crushed.

So Microsoft went with a different solution, the new button and old button are both called “Button” and the system decides what version of the buttons to load based on a small XML configuration embedded in the program file – called “a manifest”, if the program doesn’t have that manifest it gets the old version.

So, how come our program displays the new buttons in our window but the old message boxes and file dialogs?

WPF doesn’t use the system’s controls, the WPF button, for example, uses scalable vector graphics, supports animation and can even be used inside a 3D scene, the normal Windows button control doesn’t do any of that.

So, the WPF button picks up the XP look (it actually has its own XP look library, different than the one used by Windows) but when you open a message box of a file dialog you use the system’s dialog, and the system doesn’t think we support the new look – so we get the old one.

In the next post of the series we will see the application manifest needed to get the new look.

Comments on this entry:

I doubt that it’s possible to fix the MessageBox theme/style problem with the manifest alone. I hope that I am wrong because it irritates the hell out of me that I need to carry around custom code to just display a message that doesn’t look like crap. But, if I remember correctly, in WinForms implementation the MessageBox wrapper has special code that that conveys theme/style information to the Win32 control. This code is missing in the WPF wrapper (at least for .NET 3.5). It’s easy to see using the Reflector. Which goes back to your June's post about "it's never Microsoft’s bug"… Here is a related post:: http://forums.msdn.microsoft.com/en-US/wpf/thread/2bb6d0ec-c6c0-4f78-a3d1-5b54cad960a7/Like I said, I hope that I am wrong and would appreciate if you could post a solution for the MessageBox theme/style if you have one.

Sorry! My bad! Adding a manifest does fix the themes for MessageBoxes as well as the file dialogs. The extra code in WinForms (added in .NET 2.0) that I mentioned above eliminates the need for the manifest in order to get the themes.