I'm really surprised that this question does not appear to have been asked yet... if it has, but I just couldn't find it, apologies.
Ok, so my work computer has just been upgraded from Windows 7 to Windows 8. To my absolute horror, my WPF Application looks different in several ways... by different, I mean worse, uglier, controls not lined up correctly, etc. Here is an example:
Windows 7:
Windows 8:
Windows 8 problems (just from this image):
- Wrong title bar including buttons (Minimise, Close, etc.)
- Wrong size Font in title bar
- Wrong FontWeight in headings (Windows 7 SemiBold setting = Windows 8 Bold setting)
- Icon (or text) misaligned in title bar
- Icon in title bar is very blurry
- Wrong Padding and/or Margin settings spacing out items on left
- Wrong Padding and/or Margin settings reducing Textbox Heights on right
- 'Hidden' default selection colour on items on left no longer hidden
- Back to front Checkbox tick
- Images on some Buttons are very blurry
So, my question is this:
Why do WPF Applications look different between Windows 7 and Windows 8 and can this be fixed?
To clarify this, I'm not after a list of differences between WPF on the two operating systems. I'm also not after fixes for the individual points listed above. I would like for someone to explain why these UIs look different, eg. what is causing these differences. I have also heard talk of some system settings in WPF that would enable me to make the PC render the application as if it were on Windows 7, but I don't know how truthful that was.
UPDATE >>>
As @AndrasSebö kindly pointed out, there is a StackOverflow question named Windows 7 theme for WPF?, which fixes a similar problem for Windows XP. Unfortunately, it doesn't seem to have any effect on Windows 8. Are there any Microsoft users out there that actually know what differences were implemented to cause this problem? Or anyone?
UPDATE 2 >>>
Ok, so after some more testing, I'm beginning to think that this problem is not related to the Windows Theme. Using the code provided in @Gusdor's answer, I tried changing the theme to Aero
and there was no visible difference... that got me thinking. I then changed it to Luna
to test that code and it worked.
By 'worked', I mean that the Windows Theme changed, but the UI controls, or more accurately, the incorrect Padding
and Margin
remained. I then tried changing the Theme to Luna
using the XAML method mentioned by @AndrasSebö and the same thing happened... the ScrollBar
s looked different, so I could see that the Theme had changed, but the problem remained.
So now I'm thinking that this might have something to do with the fact that this is a brand new computer that I'm working on... might there be some dll or setting that I need to install? I'm really just guessing here - I have the whole Microsoft .NET Framework installed to version 4.5.1 as I'm on Windows 8.1.
This is an absolute nightmare as I don't have time to go and fix every view in this large application. Please help if you can.