Articles in this section
Category / Section

How to create filled PolyLine Node in WPF Diagram (SfDiagram)?

1 min read

You can create unfilled polyline(i.e. Polyline Connector) by using the DrawingTool and DefaultConnectorType properties of WPF Diagram (SfDiagram).

 

You can also create filled polyline(i.e. Polyline Node) by using the Node’s Shape property which basically supports PathGeometry values. There you can set dozens of points as PathFigure to create your own polyline.

C#

//Node filled Polyline 
 
var pointsCollection = new PointCollection(); 
pointsCollection.Add(new Point(300, 350)); 
pointsCollection.Add(new Point(330, 300)); 
pointsCollection.Add(new Point(370, 300)); 
pointsCollection.Add(new Point(400, 350)); 
pointsCollection.Add(new Point(370, 400)); 
pointsCollection.Add(new Point(330, 400)); 
 
var pathFigure = new PathFigure() 
{ 
   StartPoint = pointsCollection.First(), 
   Segments = new PathSegmentCollection() { new PolyLineSegment() { Points = pointsCollection } } 
}; 
 
var pathGeometry = new PathGeometry() { Figures = new PathFigureCollection() { pathFigure } }; 
 
NodeViewModel node = new NodeViewModel()  
{ 
   ID = "NodeID", 
   OffsetX = 300, 
   OffsetY = 400, 
   UnitWidth = 100, 
   UnitHeight = 100, 
   Shape = pathGeometry, 
}; 
(diagram.Nodes as NodeCollection).Add(node);

 

PolylineNode

View sample in GitHub.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied