添加命名空间:
using System.Windows.Forms;
using System.Drawing;
随后引用一个Dll : C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll
现在我们就能直接使用winform的调色板控件了。
ColorDialog colorDialog = new ColorDialog();
colorDialog.AllowFullOpen = true;
colorDialog.ShowDialog();
System.Windows.Media.SolidColorBrush scb = new System.Windows.Media.SolidColorBrush();
System.Windows.Media.Color color = new System.Windows.Media.Color();
color.A = colorDialog.Color.A;
color.B = colorDialog.Color.B;
color.G = colorDialog.Color.G;
color.R = colorDialog.Color.R;
scb.Color = color;
run.Foreground = scb;