Question: How to change the caption button foreground based on themes(light/dark) [WinUI 3 WinAppSDK 1.1p2]
See original GitHub issueThe documentation mentioned that we can customise the foreground of the caption buttons by defining resources in app.xaml. This neatly sets the colors but these colors are not responsive to the change in the theme.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
<SolidColorBrush x:Key="WindowCaptionBackground">Green</SolidColorBrush>
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled">LightGreen</SolidColorBrush>
<SolidColorBrush x:Key="WindowCaptionForeground">Red</SolidColorBrush>
<SolidColorBrush x:Key="WindowCaptionForegroundDisabled">Pink</SolidColorBrush>
</ResourceDictionary>
</Application.Resources>
I have tried defining these resources in the Dark and Light section of the dictionary, however I could not make it work. Is it that the caption buttons are ignoring these changes? or I am doing something incorrect. My App is based on WinAppSDK 1.1 preview 2.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" /><ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<Color x:Key="CaptionColor">#FFFFFF</Color>
<Color x:Key="CaptionColorDisabled" >#5DFFFFFF</Color>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<Color x:Key="CaptionColor">#E4000000</Color>
<Color x:Key="CaptionColorDisabled" >#5C000000</Color>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<Color x:Key="CaptionColor">#FFFFFF</Color>
<Color x:Key="CaptionColorDisabled" >#5DFFFFFF</Color>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<Color x:Key="CaptionColor">#E4000000</Color>
<Color x:Key="CaptionColorDisabled" >#5C000000</Color>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<SolidColorBrush x:Key="WindowCaptionForeground" Color="{ThemeResource CaptionColor}"/>
<SolidColorBrush x:Key="WindowCaptionForegroundDisabled" Color="{ThemeResource CaptionColorDisabled}" />
<SolidColorBrush x:Key="WindowCaptionBackground" Color="Transparent"/>
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled" Color="Transparent" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@harvinders i have this issue too, i used c# code for doing this. you can find my codes in ThemeHelper class https://github.com/ghost1372/SettingsUI/blob/57b2b8e147407974646cfa6294754877bfcc2398/src/SettingsUI/Tools/Helpers/ThemeHelper.cs#L83-L99
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.