ThemeManager不会更改控件的样式

时间:2018-01-19 17:42:41

标签: c# wpf mahapps.metro

我正在尝试ThemeManager的{​​{1}}并且一切运作良好,或多或少。较少的部分是一种奇怪的情况,不会改变我控制的颜色。当我应用新的重音时,文本颜色会发生变化,但例如在MahApp上我看到GroupBox仍为白色。这是我的Background

App.xaml

然后我以这种方式更改应用程序样式:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz">

<ResourceDictionary.MergedDictionaries>

    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.ListView.xaml" />

    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />

我跟随了mahapp的例子。正如我所说,只有控件不会改变背景颜色,所有其他工作都有效。

也许'因为我在 public class AccentColorMenuData { public string Name { get; set; } public SolidColorBrush BorderColorBrush { get; set; } public SolidColorBrush ColorBrush { get; set; } private ICommand changeAccentCommand; public ICommand ChangeAccentCommand { get { return changeAccentCommand ?? (changeAccentCommand = new SimpleCommand { CanExecuteDelegate = x => true, ExecuteDelegate = x => DoChangeTheme(x) }); } } protected virtual void DoChangeTheme(object sender) { var theme = ThemeManager.DetectAppStyle(Application.Current); var accent = ThemeManager.GetAccent(Locale.GetEnColor(Name)); ThemeManager.ChangeAppStyle(Application.Current.Resources, accent, theme.Item1); } } 分割了我的用户界面?谢谢你的帮助..

0 个答案:

没有答案