I am new to WPF so I am sure I am doing something wrong. I am evaluating GoXam by implementing a few features we developed using GoDiagram. I am creating a data class derived from GraphLinksModelNodeData which binds to a xaml NodePanel derivative in a DataTemplate. I need to apply a xaml symbol to my components and I am using OnInitialized in the NodePanel derivative to TryFindResource using a string key to return a ControlTemplate. This holds the xaml for the symbol. I then create a ContentControl and assign the template to its Template property then make it a child of a ViewBox. The ViewBox in turn is added to the NodePanel.InternalChildren. This all works and I am able to set up a network of linked components.
Perhaps I misunderstand what you are doing, but that seems a rather complicated way to go. There must be something seriously wrong for there to be such a long delay.
Do you really need to use a NodePanel at all? Can’t you use a DataTemplate instead of a ControlTemplate and modifying the visual tree in code?
OK, I missed out a few details. Components have between 1 and 60 ports depending on their type which we represent with a polygon (triangle). I looked through the samples and found the dynamic port example which uses lists on each side which is too heavyweight and another example uses a different DataTemplate for each node type. We would require many dozens. My solution was to build a Grid in the NodePanel code 16 x 16 and add polygons to SpotPanels to the appropriate cells. With that superstructure in place I used it to also add the symbol. Much Googling shows that binding a vector graphic is very difficult. Hence I’ve converted our SVG files to xaml and load them as described. The effect is rather good. There is some sort of blinkered logic to my progression so I’m sure I’m missing something.
Off hand I would think a SpotPanel would provide the port-positioning that you want – you still dont need a NodePanel.
But just using a NodePanel (or not) probably doesn’t really make a difference in performance. It just seems unnecessarily complicated.
However, I suspect that the problem with copy and paste is that you are including DependencyObjects in the data. Those DependencyObjects probably have references to objects you really don’t want to include in the serialized data for the clipboard. So I strongly suggest investigating the contents of the Clipboard to see what’s really there.
My guess is that you are trying to serialize the whole Diagram to the clipboard.
Normally the data that is serialized in the clipboard should just be model data – simple objects with simple string or number properties.
Thank you Walter, It’s so helpful having someone else look at a problem! You are right re the clipboard. I was storing the ports for each component (ID and points) in a List as part of the node data. On removing that all is well. I now have to redesign the whole thing…