I have a custom connectorthat displays correctly when drawn onto a xamDiagram but doesn't display correctly in the toolbox. Code is below:
public class MyConnector : DiagramConnection, IMyShape
{
public MyConnector() {
ConnectionType = ConnectionType.RightAngle; Stroke = Brushes.HotPink; StrokeThickness = 3;
}
...
public override DiagramItem Clone() {
return new MyConnector();
Hello David!
Perhaps the issue you are experiencing is because you are not specifying the StartPoint and EndPoint properties of your connector when you are adding it to the toolbox. You could try the following when you are adding the MyConnector to the toolbox:
Toolbox.Categories[2].ToolboxCategoryItems.Add(new DiagramToolboxItem() { Title = "My Connector" }); Toolbox.Categories[2].ToolboxCategoryItems[1].Item = new MyConnector() { StartPoint = new Point(0,0), EndPoint = new Point(30,30) };
Also in the Clone override you might want to use the base Clone and set the MyConnector properties accordingly, or at least copy the start and end point:
public override DiagramItem Clone() { var connector = base.Clone() as DiagramConnection; connector.ConnectionType = ConnectionType.RightAngle; connector.Stroke = Brushes.HotPink; connector.StrokeThickness = 3; // or : // var connector = new MyConnector(); // connector.StartPoint = ActualStartPoint; // connector.EndPoint = ActualEndPoint; return connector; }
Let me know if this solves your issue.
Regards,
Philip