
Howdy
I want to ask for the theme definition for the window background color it will use.
I need this color to generate a list of contrasting color to use in a line plot/chart.
I've tried getting the resources after applying the CurtrentTheme name in the thememanger, but when I do a TryFindResource on Application.Current, I get a resource not found. "var background = FindResourceColor(AssetResourceKeys.WindowBackgroundNormalBrushKey);" is what fails
What I want to do:
// now for each theme, so through and dig up the background color
// to use for the theme...
UpdateTheme(Theme.HighContrast);
var background = FindResourceColor(AssetResourceKeys.WindowBackgroundNormalBrushKey);
smThemeBackgroundColors[Theme.HighContrast] = background ?? throw new ResourceNotFoundException(nameof(AssetResourceKeys.WindowBackgroundNormalBrushKey));
UpdateTheme(Theme.Light);
background = FindResourceColor(AssetResourceKeys.WindowBackgroundNormalBrushKey);
smThemeBackgroundColors[Theme.Light] = background ??
throw new ResourceNotFoundException(nameof(AssetResourceKeys.WindowBackgroundNormalBrushKey));
UpdateTheme(Theme.Dark);
background = FindResourceColor(AssetResourceKeys.WindowBackgroundNormalBrushKey);
smThemeBackgroundColors[Theme.Dark] = background ??
throw new ResourceNotFoundException(nameof(AssetResourceKeys.WindowBackgroundNormalBrushKey));
where UpdateTheme is:
internal static void UpdateTheme(Theme theme)
{
// decode the theme if needed
theme = ResolveTheme(theme);
// Set the current app theme via a registered theme definition name
ActiproSoftware.Windows.Themes.ThemeManager.CurrentTheme = theme switch
{
Theme.Light => Resources.Properties.Resources.PenskeLight,
Theme.Dark => Resources.Properties.Resources.PenskeDark,
Theme.HighContrast => Resources.Properties.Resources.PenskeHighContrast,
_ => Resources.Properties.Resources.PenskeDark
};
// track the latest theme...
smCurrentTheme = theme;
}
Any thoughts on what to try?