Programatically add unbound nodelink

i have a use-case that requires adding unbound nodes and link them to existing nodes.

what is the recommended way to do that dynamically via code?

Why do your additional nodes need to be unbound from data?
Why not just add data to your model?

If you don’t want those nodes and links to be persisted (to XML or your database or whatever), you can mark them in some manner so that you can recognize and ignore them.

In any case, adding nodes programmatically just means adding data to a model. For data-bound parts, that’s what all of the samples do. For unbound parts, that means adding them to the Diagram.PartsModel instead of to the Diagram.Model.

But there is no built-in support for references between models.

my model.NodeSource is also the ItemsSource of a dataGrid.

the unbound nodes should be hidden in the dataGrid, but in the diagram they should be linked to data-bound nodes.

Yes, that sounds like the right approach.

the right approach e.g. hiding these nodes in the dataGrid?


After all, the converse would hold too. If you didn’t want to show in the Diagram everything that was in the data source, you could make those nodes (and links) not Part.Visible.

Or better yet, you could override PartManager.FilterNodeForData to return false for the node data that you didn’t want to show, causing the Node not to be created at all.

i am trying to have nodes shown in the diagram yet hidden in dataGrid.

i came up with unbound nodes (not in data), but now it seems like a preferred direction to filter data from dataGrid