There is some way to overwrite the MaterialDesignPaper brush #3082
-
I was able to verify that the MaterialDesignPaper brush changes dynamically when you change the mode (light,dark), There is some way to override or change the color of the brush only for the light theme, and keep its color change property? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yes, this is something that is getting a major re-work done for the 5.0.0 release. For now the easiest way to do it is to get a hold of the var paletteHelper = new PaletteHelper();
ITheme theme = paletteHelper.GetTheme();
theme.Paper = Colors.Fuchsia;
paletteHelper.SetTheme(theme); If you let the theme change from user to user you can use the var paletteHelper = new PaletteHelper();
IThemeManager manager = paletteHelper.GetThemeManager();
manager.ThemeChanged += OnThemeChanged;
UpdateBrushes();
void OnThemeChanged(object? sender, ThemeChangedEventArgs e)
{
manager.ThemeChanged -= OnThemeChanged;
UpdateBrushes();
manager.ThemeChanged += OnThemeChanged;
}
void UpdateBrushes()
{
ITheme theme = paletteHelper.GetTheme();
if (theme.GetBaseTheme() == BaseTheme.Light)
{
theme.Paper = Colors.Fuchsia;
}
paletteHelper.SetTheme(theme);
} |
Beta Was this translation helpful? Give feedback.
Yes, this is something that is getting a major re-work done for the 5.0.0 release.
For now the easiest way to do it is to get a hold of the
ITheme
instance, modify the brush, and save the change. The basic code looks like this:If you let the theme change from user to user you can use the
IThemeManager
to be notified when the theme changes and update the brush. Something like this: