Hi,
we are using XAM Diagram and I am going to add line straight line, arrow rectangle in XAMDiagram in code behind.
For that I have added following code.
diagram.Items.Add(new DiagramConnection { ConnectionType = connectionType, StartPosition = new Point(startpositionX,startpositionY), EndPosition = new Point(endpositionX, endpostionY), HorizontalAlignment = horizontalalignment, VerticalAlignment = verticalalignment, Stroke = stroke, StrokeDashArray = doublestroke, EndCapType = captype, Height = connheight, Width = connwidth });
diagram.Items.Add(new DiagramNode { ShapeType = diagramShape, Position = new Point(cordinateX, cordinateY), Height = diagramheight, Width = diagramWidth, Content = content });
DiagramNode items are showing in XAMDiagram but DiagramConnection Items are not showing in XAMDiagram. Please let us aware for us.
Your help would be appreciate.
Thanks
I am not sure if I am following why you need to convert string to DoubleCollection if you have the collection with 3 and 4 values. Here is a code snippet that is working on my side:DoubleCollection doubleColl = new DoubleCollection(); doubleColl.Add(3); doubleColl.Add(4);
diagram.Items.Add(new DiagramConnection { ConnectionType = DiagramConnectionType.Straight, StartPosition = new Point(10, 10), EndPosition = new Point(50, 50), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Stroke = new SolidColorBrush(Colors.Red), StrokeDashArray=doubleColl, Height = 50, Width = 50 }); Would you please let me know how your scenario is different?
I found the issue, I have added Dotted line and for dotted line have strokedashArray(3 4). But I am not able to convert string to DoubleCollection. Because strokeDashArray is DoubleCollectionType. I am not able to cast string to DoubleCollection Type so that I can assign strokeDash Array value. Please let us aware for that.
Hello Prikanwar,
Please find a sample project attached that is using the code snippet you provided to show connection and node objects in the diagram. If the diagram has smaller size than the items that should be displayed they will not be visible so I have set HorizontalAlignment and VerticalAlignment to ‘Strectch’. I hope this will be helpful for you. If you have any questions or concerns, feel free to let me know.