Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why WPF renders differently on different versions of Windows?

Tags:

wpf

rendering

I read that WPF uses DirectX under the hood to perform its rendering, that it doesn't rely on the dinosaurian libraries that WinForms uses to render controls.

So I made my Presentation layer with WPF and it looks the way it should under Win8.

Then I deployed the project to Windows Server 2003... to find out that my nice little custom message box looks awfully WinForms-like and somewhat clunky; the button controls are VERY similar to the WinForms ones, the expander control is no longer shown as a circled ^ arrow and looks like it was drawn in 1998 (picture the ^ arrow on an ugly square flat button that pops up when your mouse hovers over it).

From the Pro WPF in C# 2010 Bible:

Part of the promise of WPF is that you don't need to worry about the details and idiosyncrasies of specific hardware. WPF is intelligent enough to use hardware optimizations where possible, but it has a software fallback for everything. So if you run a WPF application on a computer with a legacy video card, the interface will still appear the way you designed it.

So, is this a lie? To me it is, because it doesn't appear the way I designed it.

If not, then why/how doesn't the thing render identically regardless of the machine that's running it? Is the software fallback somehow designed to mimick Win32/GDI rendering? Is there a way to get my little custom message box to look identical on Win8 and WinServer2K3?

like image 979
Mathieu Guindon Avatar asked Oct 05 '22 06:10

Mathieu Guindon


1 Answers

That has NOTHING to do with DirectX / Rendering / video card / any of that.

and EVERYTHING to do with WPF taking the DEFAULT appearance of ALL UI Elements from the Windows Theme.

If you don't want this behavior, you'll have to provide Styles and Templates for ALL UI element types, or otherwise find a way to include PresentationFramework.Aero.dll in your application and use that as the default theme library.

Take a look at this answer

like image 101
Federico Berasategui Avatar answered Oct 10 '22 02:10

Federico Berasategui