Skip to content

Windows 11 Theming Changes - #8870

Merged
dipeshmsft merged 272 commits into
dotnet:mainfrom
harshit7962:CompleteWin11Changes
Apr 19, 2024
Merged

dipeshmsft merged 272 commits into
dotnet:mainfrom
harshit7962:CompleteWin11Changes

Conversation

@harshit7962

@harshit7962 harshit7962 commented Mar 5, 2024 •

Copy link
Copy Markdown
Member

Description

The following changes includes all the modifications required to use Windows 11-based styles, themes and controls in WPF applications. It includes the following features:

  • Updated controls' look and feel
  • Ability to use system themes
  • Acrylic background support
  • Theme switching based on system theme
  • Enhanced animations

Customer Impact

Developers can use the new styles at the moment by including its resource dictionary in App.xaml. The following is syntax for the same:

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

Regression

None

Testing

Local Build Pass
Regression Testing
Sample Application Testing

Future Works

The work is in accordance to Modernizing WPF applications. There stands provisions to include better opt-in mechanism, use of customizable themes and backgrounds among others.

singhashish-wpf and others added 30 commits December 21, 2023 12:40
Need to fix the public imports
Todo:
Navigate icons not showing up
Fix Button Appearance and Calendar Button not showing
Adding win11 styles to progressbar, label and statusbar
…anges

Adding win11 styles to ScrollBar and ScrollViewer
@robert-abeo

Copy link
Copy Markdown

I hope the XAML here isn't locked in for all time. I know you all had to start somewhere but WPF UI may not have been the best base. There are other versions of the Fluent v2 theme that seem to be better in some areas. i.e. https://github.com/wherewhere/ModernWpf

What probably should have happened here is a DIRECT port of the WinUI Fluent v2 XAML styles to WPF. That should have been done clean by Microsoft rather than pulling in other projects that felt the need to deviate or do their own thing. Microsoft needs to be consistent across their UI frameworks and already have a source of truth: WinUI itself.

* Refactored WindowBackdrop, BackgroundManager, ThemeColorization

* Fix Window implicit style and Textblock inheritence

* Moved WindowBackdrop to OnSourceInitialized and added app context switch for disabling backdrop

* Initial Accent Color update fix

* Added initialization in ThemeManager. Added comments

* Added UISettings to handle accent color fetching (#34)

* Added UISettings RCW

* Made UISettings handle fallback

* Fixes UISetting Initialization
@robloo

robloo commented Apr 13, 2024

Copy link
Copy Markdown

It is very important all hard-coded references to "Segoe Fluent Icons" are replaced by a dynamic resource SymbolThemeFontFamily. See what upstream WinUI does here:

<controls:FontIconSource Foreground="{ThemeResource ComboBoxDropDownGlyphForeground}" FontFamily="{ThemeResource SymbolThemeFontFamily}" FontSize="12" Glyph="&#xE70D;" />

https://github.com/microsoft/microsoft-ui-xaml/blob/b91b3ce6f25c587a9e18c4e122f348f51331f18b/controls/dev/ComboBox/ComboBox_themeresources.xaml#L585

This will allow app developers to replace the font family on systems other than Windows 11 (i.e. get their apps to works on Windows 10 and lower). There are alternative drop-in replacements fonts available.

I'm surprised the author of this PR seems to have little knowledge of upstream WinUI source code and conventions. I would encourage a deep review and understanding of upstream code before this PR is merged in.

Co-authored-by: dipeshmsft <[email protected]>
@robert-abeo

Copy link
Copy Markdown

I hope the XAML here isn't locked in for all time. I know you all had to start somewhere but WPF UI may not have been the best base. There are other versions of the Fluent v2 theme that seem to be better in some areas. i.e. https://github.com/wherewhere/ModernWpf

What probably should have happened here is a DIRECT port of the WinUI Fluent v2 XAML styles to WPF. That should have been done clean by Microsoft rather than pulling in other projects that felt the need to deviate or do their own thing. Microsoft needs to be consistent across their UI frameworks and already have a source of truth: WinUI itself.

If the style keys (part of the public API) follow the conventions and closely match WinUI that will eliminate the majority of the future risk here. I would still like to see the control themes be based on a direct port of WinUI in the future. It seems https://github.com/Kinnara/ModernWpf might actually adopt Fluent v2 as the project is active again.

harshit7962 and others added 8 commits April 16, 2024 15:53
* Updating ListBox design

* Fixed Slider selected range

* Fixing ListBox style colors

* Fixing selected range offset issue

---------

Co-authored-by: Rishabh Chauhan <[email protected]>
Co-authored-by: dipeshmsft <[email protected]>
* Updatating OS version check

---------

Co-authored-by: dipeshmsft <[email protected]>
* Removed TextBlock Style
* Added comments for new default font size
* Renaming the project

* Fixing Merge Conflicts

* Correcting FluentWindows path of fonts file

---------

Co-authored-by: dipeshmsft <[email protected]>
@dipeshmsft
dipeshmsft changed the base branch from feature/win11theming/base to main April 19, 2024 12:43
@Kuldeep-MS
Kuldeep-MS self-requested a review April 19, 2024 13:27

@Kuldeep-MS Kuldeep-MS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dipeshmsft
dipeshmsft merged commit fb28902 into dotnet:main Apr 19, 2024
@mthalman

mthalman commented May 6, 2024

Copy link
Copy Markdown
Member

These changes include a different license header compared to what is used elsewhere. Why is that?

Here's an example of a new file that was added with this PR:

// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.

Versus the standard license header used elsewhere:

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

The former is causing a false positive for a BSD type of license by our license detection for some reason (see dotnet/source-build#4373). We can filter that out but I'm wondering why the license header is different here in the first place.

@Apollo199999999

Copy link
Copy Markdown

I found another library which has most of the Fluent v2 styles implemented in WPF: https://github.com/iNKORE-NET/UI.WPF.Modern

Looking at its controls gallery, the control styles seem to match WinUI more closely. Perhaps it can be used as a reference?

@MichaeIDietrich

Copy link
Copy Markdown
Contributor

This PR is already merged, you shouldn't try to create a new discussion here. Better go to this issue #8991 and place your comments there.

And by the way your suggestion was also mentioned in the initial discussion about bringing Windows 11 theming to WPF: #8533 (comment)
But I agree, comparing the control gallery apps with the one from WinUI, I am also on the side that the repo you refer to better matches the current fluent styling, but it has also its flaws.

@ThomasGoulet73

Copy link
Copy Markdown
Contributor

Also, the repo you linked is licensed using an LGPL license which I believe is incompatible with the MIT license of this repo.

@github-actions github-actions Bot locked and limited conversation to collaborators Jun 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

PR metadata: Label to tag PRs, to facilitate with triage Win 11 Theming

Projects

Status: ☑ Done

Development

Successfully merging this pull request may close these issues.