问题
How can I draw a line in XAML using a System.Drawing.Color
? A solution without a converter would be nice.
XAML:
<Line
X1="10" Y1="10"
X2="20" Y2="10"
Stroke="{Binding Color}" StrokeThickness="4" />
Code:
System.Drawing.Color Color = System.Drawing.Color.Black;
回答1:
You need to bind a Brush to the Stroke property, in particular a SolidColorBrush, which accepts a color.
However, you need to convert from System.Drawing.Color to System.Windows.Media.Color, e.g. by passing the R, G, and B values to the FromRgb method.
来源:https://stackoverflow.com/questions/19658064/use-system-drawing-color-to-draw-a-line-in-wpf