Why won't my WPF app use Windows 11 styles?

Update July 2024 - Microsoft has uploaded a WPF Gallery Preview app to the Microsoft Store which shows the new Windows 11 styles for WPF which are currently being worked on.

Update 3/12/2023: Microsoft has outlined the scope of adding Windows 11 themes to WPF, you can see it on GitHub here. Additionally, the scope mentions dark mode so this is good news if you want to support dark mode in your app here. See the latest update from Microsoft on WPF's GitHub repo here.


If you've used Windows 11, you may have noticed that WPF apps still look like they did on Windows 10 and don't use Windows 11/system visual styles - controls use the same colours as they did on Windows 10 and don't have Windows 11 style rounded corners (aside from top level windows) and don't look any different than they did on Windows 10. Meanwhile, in Windows Forms apps, most of the controls do look updated.

Tip: If the issue you're having is with some controls such as MessageBoxes and WindowsFormsHosts not using visual styles - so looking like they're running on very old versions of Windows like Windows 95 - read this article here.

WPF controls compared to Windows Forms controls on Windows 11
WPF controls compared to Windows Forms controls on Windows 11

Why this happens

To understand why this happens, we first have to understand how visual styles work in Windows. Visual styles was a feature initially released in Windows XP and allowed for much better looking controls that could contain more than just solid colours and could be customisable by the user. In Windows XP, users could choose between the Blue, Silver and Olive visual styles or could choose to disable visual styles and have controls appear as they did in previous versions of Windows. Microsoft also provided additional visual styles such as the Media Center and Zune styles. These visual styles are stored as images in 'C:\Windows\Resources' as .msstyles files and are used by the GDI (Graphics Driver Interface) based common controls and many Windows Forms controls. WPF came out in 2006 as part of .Net Framework 3.0 and was originally known as 'Avalon', which you may have heard of from Windows Longhorn. Windows Vista, which comes preinstalled with .Net Framework 3.0, also come out in 2006. Windows Vista included a new visual style to replace the Windows XP ones but still used the same visual style system (though Windows Vista introduced the Desktop Window Manager (DWM), which can be used instead of GDI to render parts of windows such as title bars, and does not use the same visual styles that traditional GDI based versions of these parts use), however, a new visual style system was introduced with WPF with separately defined visual styles that are vector based as opposed to using prerendered raster images - this allows the controls to scale better to different screen resolutions and DPI (Dots Per Inch) scaling settings (Tip: If you have issues where your WPF UIs appear blurry, read this article). WPF's visual styles are stored in various DLL files included with the .Net Framework, for example, the Windows Vista/7 visual styles are stored in PresentationFramework.Aero.dll and the Windows XP blue style is stored in PresentationFramework.Luna.dll. Since WPF is compatible with Windows XP, all the in-built visual styles in Windows XP were recreated with vector graphics in WPF - you might even notice this if you have seen both a WPF button and a Windows Forms button for example in Windows XP with high DPI settings - the WPF button will look smoother than the Windows Forms one, as shown in the screenshot below:

A screenshot of a WPF and Windows Forms Button using the Windows XP silver style. The WPF ones looks much smoother since it is using vector graphics, rather than a stretched image.
A screenshot of a WPF and Windows Forms Button using the Windows XP silver style. Notice how much smoother the WPF one looks since it is using vector graphics, rather than a stretched image.

Extra: WPF and Windows Forms UIs look very similar when using the Windows classic/standard/high contrast themes (i.e. themes that don't use visual styles) because, when using these themes, the colours are provided as part of the theme (no images are used, just basic colour values) and both Windows Forms and WPF use these same colours. When using themes with visual styles, colours provided with the theme itself are only used in some places, other places use mostly images (for Windows Forms) provided with Windows or vector graphics (for WPF) provided with the .Net Framework.

Where we are today

These days, the original visual style system introduced in Windows XP is still used, and so is WPF's. Microsoft has also introduced newer UI frameworks with their own visual style systems such as UWP and WinUI. Microsoft is currently in the process of updating the WPF visual styles to include visual styles for Windows 11, but it is not released yet. In fact, the last visual styles in WPF were for Windows 8, and these same visual styles are used on Windows 10 and 11, hence making WPF user interfaces look quite dated by default. Microsoft has only added new Windows 11 visual styles for WinUI and for the original visual style system introduced in Windows XP - hence why WinUI, GDI and Windows Forms user interfaces look more up to date on Windows 11.

What can be done about it

So what can be done about this? Well, the good news is that Microsoft is working on adding new visual styles to WPF for Windows 11 and that they are planning on adding both light and dark modes for the Windows 11 visual styles. The bad news is that they are only planning on bringing this to .NET (formally .Net Core) and not the .Net Framework, so only apps using .NET can get these new styles. So, if you want to take advantage of these visual styles, the best way to do this is to update your apps to use the latest version of .NET. The latest version of .NET currently is .NET 8.0 and Microsoft plans to bring updated WPF styles to .NET 9 as per this scope. If you're coming from the .Net Framework, Microsoft has some information on migrating to .NET here. Additionally, here's some more information from Microsoft that might be helpful for migrating from .Net Framework to .NET:

Note: Certain technologies such as the original Microsoft Edge WebView for WPF and Windows Forms and the XamlHost for WPF and Windows Forms, do not work with versions of .NET greater than 3.1. So usage of these could make it hard to upgrade. The old Internet Explorer based WebBrowser control still works in .NET 8 as well and can be upgraded to support newer web standards and more modern behaviours by disabling various compatibility behaviours which cause it to act as if it's 2009. The Microsoft Edge Chromium based WebView2 is now available for WPF and Windows Forms. However, there is no replacement yet for XamlHost as WinUI 3 still does not have an XamlHost for WPF and Windows Forms.

How you can help

Some ways you can help bring Windows 11 styles to your WPF UIs are:

Summary

So to summarise, the reason WPF controls still look the same as they did in Windows 10 whereas many Windows Forms controls used updated Windows 11 styles is because WPF and Windows Forms get their visual styles from different places, and the visual styles WPF uses haven't been updated for Windows 11, whereas the visual styles Windows Forms uses has. Luckily, Microsoft is working on updated visual styles for WPF, including dark mode support, so hopefully WPF gets Windows 11 visual styles in the near future.

Did this guide help you? Do you have anything to add? Do you know or do you work on/have created any libraries that bring more modern visual styles to WPF? Let us know in the comments! Also, if this guide did help you and you use an AdBlocker and you want to support us, consider disabling it for this site - if you do, it will be greatly appreciated!

Follow us to be notified when we release new guides:

Comments

Popular posts from this blog

How to show placeholder text in a WPF TextBox in C# and VB

How to enable dark title bar in WPF and Windows Forms/WinForms apps in C# and VB

How to use modern icons in XAML in WPF on Windows 10 and 11

How to change the colour of a WPF or Windows Forms/WinForms title bar in Windows 11 in C# and VB

Microsoft WebView2: How to check if the WebView2 runtime is installed in C# and VB