Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I'm trying to draw in a WPF Canvas, some polylines with border.
For that purpose i've used a StreamGeometry, a PathGeometry and a "Path".
This is my code:

C#
StreamGeometry geom = new StreamGeometry();

//this method fills the StreamGeometry with a polyline
DrawLines(geom, polyObj);

PathGeometry pathGeometry = geom.GetWidenedPathGeometry(new Pen(Brushes.Black, 10));
GeometryDrawing geoDrawing = new GeometryDrawing();
geoDrawing.Geometry = pathGeometry;

Path myPath = new Path();

myPath.Fill = Brushes.LightGreen;
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 0.4;
myPath.Name = "tratta"+tratta.id;
myPath.Data = pathGeometry;
myPath.StrokeLineJoin = System.Windows.Media.PenLineJoin.Round;

canvas.Children.Add(myPath);


The code is working, but when a polyline has more than two vertex, i obtain this graphic problems on a junction:

Image - Junction

How can i resolve this problems? Thanks in advance
Posted
Updated 17-Mar-15 23:56pm
v4
Comments
Kenneth Haugland 18-Mar-15 6:50am    
You could use DrawingVisuals, but that seems to be a bit over the top for this. What happens if you try different joins?

1 solution

C#
canvasGeomentry.Child.Add(new Polyline())
{
Points=new PointCollection(new List(point))
{
new Point (x1,y1), new Point(x2,y2);
}
}

 
Share this answer
 
Comments
Kenneth Haugland 18-Mar-15 11:47am    
Ehm, I don't see how that would solve the issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900