-
Hi, My WPF app needs to support theming, I've also just migrated from 1.6 to 2.4.5. I can change themes and accents and my elements and backgrounds follow light & dark as expected...mostly, flyouts have transparent elements since migrating! My text however is not inverting to remain visible. My users can configure the color of text themselves or use a theme color so I'm reading the text as a string and applying it, e.g. tb.Foreground = new BrushConverter().ConvertFromString(textcolor) as SolidColorBrush; // for regular colors like red, blue or hex In pre 2.0 I read that BlackBrush should be used, in post 2.0 this brush is called MahApps.Brushes.ThemeForeground (found here). For me, the text just stays black and does not invert. I've tried a few other MahApps.Brushes too and none invert to be readable in both dark and light uses. What should I be using? I'm using Mahapps.Metro 2.4.5, W10x64, VS2017, .Net 4.6.1. Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @sarsw try this: private void ColorPicker_SelectedColorChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<System.Windows.Media.Color?> e)
{
App.Current.Resources["MahApps.Brushes.Text"] = new SolidColorBrush(e.NewValue ?? Colors.Black);
App.Current.Resources["MahApps.Brushes.ThemeForeground"] = new SolidColorBrush(e.NewValue ?? Colors.Black);
} I found the needed keys here: MahApps.Metro/src/MahApps.Metro/Styles/Themes/Theme.Template.xaml Lines 67 to 69 in d25cbe6 Happy coding |
Beta Was this translation helpful? Give feedback.
-
Thanks, "App.Current.Resources["MahApps.Brushes.Text"] = new SolidColorBrush(e.NewValue ?? Colors.Black);" set me down the right path. At startup I detect the Dark or Light mode in use (theme.BaseColorScheme) and set my theme brush resource accordingly, that gets picked up when used in the displays, 👍 Steve |
Beta Was this translation helpful? Give feedback.
Hi @sarsw
try this:
result:
I found the needed keys here:
MahApps.Metro/src/MahApps.Metro/Styles/Themes/Theme.Template.xaml
Lines 67 to 69 in d25cbe6