dotnet / dotnet/wpf

First-class support for custom themes

Open
#110 1 comment 20 reactions 0 assignees View on GitHub
API suggestion Enhancement Requested
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

It is currently not possible to use a custom theme as a drop-in replacement for a system theme. While it *is* possible to style everything, it requires more cumbersome work that is easily missed.

For example:
- Custom styles outside of the custom theme (e.g. local styles in a `UserControl`) always require an explicit `BasedOn="{StaticResource {x:Type ...}}"` or else they are based on the system theme.
- Inheritance does not work. Normally `ListView` without a `GridView` uses the `ListBox` style, but providing a custom one is not enough, it has to be explicitly set on the `ListView`.
- Providing a style for `ContextMenu` does not style the built-in one of textboxes or scrollbars. A prominent example where this can be seen is Visual Studio:
![wpf1](https://user-images.githubusercontent.com/51795/49605011-b52c0280-f98f-11e8-83e1-55cf7431466e.png)

[My high-quality Aero themes for WPF](https://gix.github.io/PresentationTheme.Aero/) use reflection and method hooking to solve these problems (But that's just a brittle hack. In fact, it breaks on .NET Core because tiered compilation makes hooking more difficult.). It does so by replacing `System.Windows.SystemResources.FindDictionaryResource`, normally responsible for locating the theme resource assembly and style for a given type or resource key, with one that can load custom resource dictionaries.

So my wish would be for adoption of a public API to set policies for resource loading, at least for `PresentationFramework.dll`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.