Repository navigation
Closed
Labels
difficulty/medium 🤔Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUIkind/bugSomething isn't workingproject/resources 🈷️Categorizes an issue or PR as relevant to resources and localization (Resources, Assets,...)project/styling 👔Categorizes an issue or PR as relevant to element styling
Description
Current behavior
When SystemAccentColor is overwritten, it is not applied to derived resources like SystemColorControlAccentBrush.
Expected behavior
Should apply the color to all derived resources.
How to reproduce it (as minimally and precisely as possible)
<Application
x:Class="HealthApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:HealthApp">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</ResourceDictionary.MergedDictionaries>
<Color x:Key="SystemAccentColor">#E64A19</Color>
</ResourceDictionary>
</Application.Resources>
</Application>
On main page:
<Grid Background="{ThemeResource SystemColorControlAccentBrush}"></Grid>
Probable reason for the issue
In Generic.xaml, each theme has:
<!-- Added manually (not part of UWP's SystemResources.xaml) -->
<Color x:Key="SystemColorHighlightColor">#FF3399FF</Color>
<Color x:Key="SystemAccentColor">#FF0078D7</Color>
<SolidColorBrush x:Key="SystemColorControlAccentBrush"
Color="{StaticResource SystemAccentColor}" />
I guess the SystemAccentColor is set as StaticResource, and providing a custom one in does not overwrite it for SystemColorControlAccentBrush.
Workaround
Define the SystemColorControlAccentBrush manually as well in App.xaml:
<Color x:Key="SystemAccentColor">#E64A19</Color>
<SolidColorBrush x:Key="SystemColorControlAccentBrush"
Color="{StaticResource SystemAccentColor}" />
Environment
Nuget Package:
Package Version(s):
Affected platform(s):
- iOS
- Android
- WebAssembly
- WebAssembly renderers for Xamarin.Forms
- macOS
- Windows
- Build tasks
- Solution Templates
Visual Studio:
- 2017 (version: )
- 2019 (version: )
- for Mac (version: )
Metadata
Metadata
Assignees
Labels
difficulty/medium 🤔Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUIkind/bugSomething isn't workingproject/resources 🈷️Categorizes an issue or PR as relevant to resources and localization (Resources, Assets,...)project/styling 👔Categorizes an issue or PR as relevant to element styling
Activity
MartinZikmund commentedon Nov 2, 2020
@davidjohnoliver actually it seems this could just about making sure the
SystemColorControlAccentBrushand related useThemeResourceinstead ofStaticResourcewhen referencing the accent color, correct?davidjohnoliver commentedon Nov 2, 2020
That should hopefully do it, yes.
MartinZikmund commentedon Nov 4, 2020
It turns out this actually does work in the end. Overwriting just the
Coloris not possible, not even in UWP.What does work is to override the brushes:
This properly overrides accent color and highlight accent color and these are then even reflected on controls like
ToggleButtondavidjohnoliver commentedon Apr 28, 2021
@MartinZikmund I'm not sure why you closed this issue? Putting the following
App.Resourcesworks on UWP, but not with Uno:(eg to change checked background of
CheckBox)MartinZikmund commentedon Apr 28, 2021
Probably I did something wrong when testing on UWP back then. Reopening 👍
jeromelaban commentedon Jan 27, 2022
Fixed in Uno latest, single-file merged dictionaries allow for the resolution to work as intended when using the resource explicitly, but it won't override the color when defined in fluent styles (even in WinUI).
Closing for now.