using System.Drawing;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media;
namespace WpfApp2
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
ColorDialog colorDialog = new ColorDialog();
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)//调用颜色选择器对话框
{
//提取选中的颜色
SolidBrush sb = new SolidBrush(colorDialog.Color);
SolidColorBrush solidColorBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(sb.Color.A, sb.Color.R, sb.Color.G, sb.Color.B));
myText.Foreground = solidColorBrush;//改变字体颜色
}
}
}
}