Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UiApplication forces system accent color on startup and there is no "good" way to disable that #1609

@DoctorKrolic

Description

@DoctorKrolic

Is your feature request related to a problem? Please describe

When updating our app from WPF-UI 4.0.2 to 4.1.0 our app suddenly started to pick up system accent color for WPF UI controls despite we previously put effort into blocking it. After investigation the problem turned out to be caused by seemingly unrelated change made in #1413. In that PR FontIcon class started referencing UiApplication.Current.Resources property, which internally initializes a resource dictionary and unconditionally applies system accent color:

try
{
Wpf.Ui.Appearance.ApplicationAccentColorManager.ApplySystemAccent();
var themesDictionary = new Markup.ThemesDictionary();
var controlsDictionary = new Markup.ControlsDictionary();
_resources.MergedDictionaries.Add(themesDictionary);
_resources.MergedDictionaries.Add(controlsDictionary);
}
catch { }

In our design system we have fixed color scheme and do not plan do adapt to system accent color. We would like to have a way to disable applying it on startup.

Describe the solution you'd like

Seems like adding a new boolean switch property to UiApplication would be enough:

namespace Wpf.Ui;

public class UiApplication
{
    public bool ApplySystemAccentColor { get; set; }
}

By setting this property to false before window initialization the color scheme of WPF-UI controls will not be changed according to system accent color

Describe alternatives you've considered

Don't set system accent color upon resource initialization at all since this behavior is not intuitive and leave this decision up to the user. The color can be applied via ApplicationThemeManager as they desire

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions