Reputation: 39
I'm using WPF to draw the polyline with certain width, the sample code is as follows:
DrawingContext.DrawGeometry(Brushes.Yellow, new Pen(Brush, polylineWidth), streamGeometry);
where the streamGeometry is the geometry of the polyline.
The result Looks like:
However, I'd like to add borders around the polyline, which looks like:
I know I can draw two polylines with different width (one for the black background, and the other for the color I want to render) I just wonder is there any API or some elegant way to achieve this?
Upvotes: 1
Views: 1361
Reputation: 2519
There is only one additional step needed to accomplish that. Create a new shape out of your polyline (the thickness of the polyline included). Use:
var pathGeometry = streamGeometry.GetWidenedPathGeometry (new Pen(Brushes.Black, polylineWidth));
Then call
DrawingContext.DrawGeometry(Brushes.Yellow, new Pen(strokeBrush, strokeThickness), pathGeometry);
and you are done.
Upvotes: 2