问题
System.Drawing.Color drawRedColor = System.Drawing.Color.Red;
System.Windows.Media.Color mediaColor = ?drawRedColor.ToMediaColor();?
回答1:
How about:
using MColor = System.Windows.Media.Color;
using DColor = System.Drawing.Color;
...
public static MColor ToMediaColor(this DColor color)
{
return MColor.FromArgb(color.A, color.R, color.G, color.B);
}
EDIT: Fixed the 'unpacking' of the ARGB.
回答2:
System.Windows.Media.Color mediaColor = System.Windows.Media.Color.FromRgb(Color.Red.R, Color.Red.G, Color.Red.B);
来源:https://stackoverflow.com/questions/4104910/convert-system-drawing-color-to-system-windows-media-color