I’m looking for a way to check which theme is my WinUI application currently using?
Users can select the theme they want from the settings as: dark, light or default, but in the end the app is either dark or the light.
Say if you want to pick a color contrasting with your app current theme it could look like that:
if (ActualTheme == ElementTheme.Default)
{
// Currently using system default so check which it is to choose our color
iColor = Application.Current.RequestedTheme == ApplicationTheme.Light ? Colors.Black : Colors.White;
}
else
{
// Not using system default theme so choose our color according to our theme override
iColor = ActualTheme == ElementTheme.Light ? Colors.Black : Colors.White;
}
Where ActualTheme is a method of FrameworkElement so you could run that code from any of your Pages for instance.