我从this link here复制了ResourceDictionery,它似乎与现有的Accent.xaml文件相同,并将重点颜色更改为我自己的自定义颜色。
我在Application的资源中添加了ResourceDictionary。
我看到的问题是对话框按钮的背景颜色没有获得我的自定义强调色。如果我猜它似乎是钴色调的颜色。
编辑更新问题如上所述,我只将新的Accent Colors添加到Application的ResourceDictionary中。这似乎适用于大多数事情,但不适用于对话框的按钮颜色。我测试了Mahapps.Metro样本并发现如果你只将自定义Accent ResourceDictionary添加到Applications资源,那么Dialog中按钮的背景颜色应该是AccentColor将不起作用。我解决了(并且可以从指令中读取:-))你需要使用ThemeManager并覆盖OnStartUp事件。
现在这会导致问题编号2.这是我的代码。 ThemeManger的DetectAppStyle函数不会返回任何内容。
Protected Overrides Sub OnStartup(e As StartupEventArgs)
Try
ThemeManager.AddAccent("NewAccent1", New Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/NewAccents/NewAccent1.xaml"))
Dim theme = ThemeManager.DetectAppStyle(Application.Current)
ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("NewAccent1"), theme.Item1)
Catch ex As Exception
Debug.Print(ex.Message)
End Try
MyBase.OnStartup(e)
End Sub
答案 0 :(得分:1)
MahApps对话框的肯定按钮使用基于AccentedDialogSquareButton
的{{1}}样式。您可以在MahApps的源代码树中找到它们:
所有其他按钮使用
中定义的AccentedSquareButtonStyle
样式
如果要覆盖此行为,则需要更改为SquareButtonStyle
和BaseMetroDialog.xaml
(对于“确定”按钮)。