Open MartinZikmund opened 1 year ago
This may be due to how DP default values work in WinUI.
Whenever a default value needs to be read, DependencyProperty::GetDefaultValue
is called. For Foreground DPs specifically, that's calculated from CoreServices and is cached there (CCoreServices::GetDefaultTextBrush
).
Then, whenever you set RequestedTheme
, it will cause CFrameworkElement::NotifyThemeChangedForInheritedProperties
to be called which will re-lookup DefaultTextForegroundThemeBrush
. It may be that they are called at different timings of the app lifecycle where it yields different results? I'm not sure, such a hypothesis looking at the relevant pieces of code here.
Describe the bug
WinUI sets the
DefaultTextForegroundThemeBrush
for light theme to#E4000000
instead of fully opaque black. However, this is not applied consistently unless element-levelRequestedTheme
is set explicitly toLight
(e.g.TextBlock.Foreground
,ContentPresenter.Foreground
andBitmapIcon.Foreground
are all still fully opaque black).Steps to reproduce the bug
MainPage.xaml
orMainWindow.xaml
add the following content:App.xaml
and set theRequestedTheme
there toLight
).Expected behavior
The
#E4000000
color should be applied consistently (or fully opaque black should be used).Screenshots
NuGet package version
WinUI 3 - Windows App SDK 1.3.0: 1.3.230331000 WinUI 3 - Windows App SDK 1.2.5: 1.2.230313.1 UWP + WinUI 2.8
Windows version
Windows 11 (22H2): Build 22621
Additional context
Happens even in WinUI 2.8 + UWP