我想将颜色从cololrdialog转换为wpf颜色我该怎么做? [英] i want to convert the color from cololrdialog to wpf color how can i do that?
本文介绍了我想将颜色从cololrdialog转换为wpf颜色我该怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将颜色从cololrdialog转换为wpf颜色
我该怎么做?
private void colorpiker_MouseLeftButtonDown(object sender,MouseButtonEventArgs e)
{
System.Windows.Forms.ColorDialog ColorColection = new System.Windows.Forms.ColorDialog();
ColorColection.ShowDialog();
if(ColorColection.ShowDialog()== System.Windows.Forms.DialogResult.OK)
{
<! - 此处dosnt工作 - >
wpfcolor.Fill = new ColorConverter(ColorColection.Color);
}
}
解决方案
请参阅此CodeProject文章: WPF中的WinForms.ColorDialog [ ^ ]。
但是,当然,使用专为WPF设计的颜色对话框总是更好。请参阅Extended WPF Toolkit的WPF的ColorPicker
编辑器。您可以使用Community Edition:
http://wpftoolkit.codeplex.com/ wikipage?title = ColorPicker& referTitle = Home [ ^ ],
http://wpftoolkit.codeplex.com/ [ ^ ]。
< dd> -SA
获取Color的一种简单方法是使用:public static System.Windows.Media.Color Convert( this System.Drawing.Color sourceColor )
{
return System.Windows.Media.Color.FromArgb(sourceColor.A,sourceColor.R,sourceColor.G,sourceColor.B );
}然后,你需要做的就是
wpfColor.Fill = new SolidColorBrush(ColorCollection。 Color.Convert());
i want to convert the color from cololrdialog to wpf color
how can i do that?
private void colorpiker_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
System.Windows.Forms.ColorDialog ColorColection =new System.Windows.Forms.ColorDialog();
ColorColection.ShowDialog();
if (ColorColection.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
<!--here dosnt work-->
wpfcolor.Fill =new ColorConverter(ColorColection.Color);
}
}
解决方案
Please see this CodeProject article: WinForms.ColorDialog in WPF[^].
But of course, it would always be better to use a color dialog designed for WPF. Please see theColorPicker
editor for WPF, from Extended WPF Toolkit. You can use Community Edition:
http://wpftoolkit.codeplex.com/wikipage?title=ColorPicker&referringTitle=Home[^],
http://wpftoolkit.codeplex.com/[^].
—SA
A simple way to get the Color, is to use this:public static System.Windows.Media.Color Convert(this System.Drawing.Color sourceColor) { return System.Windows.Media.Color.FromArgb(sourceColor.A, sourceColor.R, sourceColor.G, sourceColor.B); }Then, all you need do is
wpfColor.Fill = new SolidColorBrush(ColorCollection.Color.Convert());
这篇关于我想将颜色从cololrdialog转换为wpf颜色我该怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文