1、添加引用
路径如下:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\vx.x.x\
2、写入事件
private void Button_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog(); if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { System.Drawing.SolidBrush sb = new System.Drawing.SolidBrush(colorDialog.Color); SolidColorBrush solidColorBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(sb.Color.A, sb.Color.R, sb.Color.G, sb.Color.B)); this.Background = solidColorBrush; } }
3、效果