Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF/XAML doesn't look like system theme

Tags:

c#

wpf

I would expect a default project for WPF to use the exact system theme, but the default theme for WPF looks somewhat akin to Windows 10, but not quite. And rather ugly if I had my opinion. My question is - how do I make WPF follow system theme?

Screenshot below is running in Windows 11. It's just a deafult project using File > New Project > WPF Application

Image showing WPF

This screenshot is from some random Visual Studio menu. Obviously these buttons look much different.

enter image description here

like image 825
AlgoRythm Avatar asked May 11 '26 19:05

AlgoRythm


2 Answers

WPF: Windows 11 theme support in .NET 9/10

For consumer applications built on WPF and running on Windows 11, this feature enables them to leverage modern design elements and behaviors. This includes features such as:

  • Fluent Light and Dark theme support
  • Rounded corners for controls, and
  • Windows 11 design styles for controls

WPF Gallery Preview - Working example in the Microsoft Store

Fluent Light theme Fluent Dark theme

This can be enabled:

Change the framework version to 9.0 in the csproj file

<TargetFramework>net9.0-windows</TargetFramework>

P.S. Minimum version of Visual Studio 2022 v17.12 with .NET 9

Adding the following to your App.xaml

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Official Wiki

Brief evolution of Windows over the years

Brief evolution of Windows over the years

Ways to connect topics:

Source="pack://application:,,,/PresentationFramework.Classic;component/Themes/Classic.xaml"
Source="pack://application:,,,/PresentationFramework.Luna;component/Themes/Luna.normalcolor.xaml"
Source="pack://application:,,,/PresentationFramework.Royale;component/Themes/Royale.normalcolor.xaml"
Source="pack://application:,,,/PresentationFramework.Aero;component/Themes/Aero.normalcolor.xaml"
Source="pack://application:,,,/PresentationFramework.Aero2;component/Themes/Aero2.normalcolor.xaml"
Source="pack://application:,,,/PresentationFramework.AeroLite;component/Themes/AeroLite.normalcolor.xaml"
Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.xaml"
like image 114
Andrei Krasutski Avatar answered May 14 '26 08:05

Andrei Krasutski


I think the closest you will get to this is by using ModernWPF.

This is basically a port of WinUI to WPF, but only up until WinUI 2.6 when Microsoft introduced the Windows 11 styles. The project currently has open issues logged for Windows 11 styles but it's still up in the air as for whether it'll gain support for these anytime soon.

like image 45
Jonas Avatar answered May 14 '26 07:05

Jonas