如何设置按钮的样式?我使用 Xceed.wpf.toolkit
Xceed.Wpf.Toolkit.MessageBox mbox = new Xceed.Wpf.Toolkit.MessageBox();
System.Windows.Style style = new System.Windows.Style(typeof(System.Windows.Controls.Button));
style.Setters.Add( new System.Windows.Setter(System.Windows.Controls.Button.ForegroundProperty, Brushes.DarkGreen));
mbox.OkButtonStyle = style;
我得到了错误
System.Windows.Markup.XamlParseException: ''System.Drawing.SolidBrush' is not a valid value for the 'System.Windows.Documents.TextElement.Foreground' property on a Setter.'
最佳答案
一定要使用 WPF 库而不是 WindowsForms 或 GDI+ 库...
您应该使用什么:System.Windows.Media.Brushes
,其中包含 DarkGreen
作为 System.Windows.Media.SolidColorBrush
(在 PresentationCore 中.dll)。
您当前使用的是 System.Drawing.Brushes
和 System.Drawing.SolidBrush
。
关于c# - 在后台代码中设置按钮样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43474507/