[API Proposal]: FluentWindows Theme Switch in WPF
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
## Background and motivation
With the introduction of FluentWindows ( Win11 ) theme, we want to allow developers to be able to enable disable and switch themes in their WPF applications. Irrespective of if we provide an API in .NET 9, I believe that we should provide a way for developers to choose only Light, Dark theme or respond to system theme changes.
Part of effort - https://github.com/dotnet/wpf/discussions/8655
This is inspired and a minified version of the #8759
Before going through the alternatives, I would like to bring to the point, since we are so close to the code completion deadline for .NET Preview 7, that if we choose to implement the API, we keep it ***experimental***, so that we have room for further discussion in future.
# API Proposal
## Current Proposal
```csharp
public class Application
{
[Experimental]
public string Theme { get; set; }
}
public class Window
{
[Experimental]
public string Theme { get; set; }
}
```
The accepted values for the theme properties can be - `None`, `System`, `Light` and `Dark`
As mentioned above, these APIs will be `Experimental` until we have further discussions and have a better way to handle theme ( default ) styles in .NET 10.
#### Behavior of the APIs
1. When `Window.Theme = System / Light / Dark` it will take precdence over `Application.Theme` and we will load the Fluent styles for window. In case, of `System` Window will respond to System theme changes.
2. When `Application.Theme = System / Light / Dark` and `Window.Theme = None` then window will follow the application.
3. In case none of the above properties are set, we will get `Aero2` by default.
4. Accent color changes will be received by every window irrespective of the Theme property values. If Theme value is `None`, then Accent colors don't come into play.
5. Default values for both `Theme` properties is `None`.
### Alternative Designs
_No response_
### Risks
_No response_
cc: @dotnet/dotnet-wpf-triage @pomianowski
Contributor guide
Assessment
This issue has not been assessed yet.