Hello,
Chances are you don’t even need to use a NodePanel.
I don’t understand what it is that you cannot access. “{Binding Path=Data.SomeProperty}” ought to work fine to get properties on the data that the Node is bound to.
If you want to programmatically change some Grid properties, the value of Part.VisualElement is a reference to the root visual element for that Part, which is a NodePanel in your simple template, but would just be the Grid if you remove the NodePanel from the template as I suggest.
If you want to access particular named elements in the visual tree of the Part, you can call the Part.FindNamedDescendant method.
I have the following code in XAML
Normally when you want to modify the appearance (or behavior) of the elements of a Node, you just need to modify the properties of some data in your model. Data-binding takes care of automatically updating the FrameworkElements in the visual tree of the corresponding node.
But let’s say that you didn’t want to use XAML and data-binding, perhaps because it was too inconvenient or too slow. Instead you want to modify the visual tree programmatically. Here’s how to do that.
Basically you want to call PartManager.FindNodeForData to find the Node corresponding to the data that you care about.
Then you want to call Part.FindNamedDescendant to find a particular FrameworkElement that you can modify.
Something like:
Node node = myDiagram.PartManager.FindNodeForData(...some data..., myDiagram.Model);
if (node == null) return;
Grid grid = node.FindNamedDescendant("control") as Grid;
if (grid == null) return;
... modify Grid or create and add new visuals to this Grid ...