如何设置按钮的样式?我使用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;
Run Code Online (Sandbox Code Playgroud)
我得到错误
System.Windows.Markup.XamlParseException: ''System.Drawing.SolidBrush' is not a valid value for the 'System.Windows.Documents.TextElement.Foreground' property on a Setter.'
Run Code Online (Sandbox Code Playgroud)
确保使用WPF库,而不是WindowsForms或GDI +库。
您应该使用什么:System.Windows.Media.Brushes包含DarkGreen为System.Windows.Media.SolidColorBrush(在PresentationCore.dll中)。
您当前使用的是System.Drawing.Brushes和System.Drawing.SolidBrush。
| 归档时间: |
|
| 查看次数: |
1289 次 |
| 最近记录: |