Grid in NodePanel

Hello,

I want to place any controls in a NodePanel, for example a Grid.
In former versions of GoXam we solved it by generating a picture and place this picture in the NodePanel. Now we want the ability to interact with this control for example reorder a column of a table. Of course it is no problem to add a grid to the NodePanel but the problem I have it is that I can´t access the Grid via Binding=Data...
Is there any way to do this?
Tom

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

In the TextBlock it is no problem to bind data via Binding Path=Data.FontSize for example. The problem I have is that in the grid-control there is no property in XAML which I can reference in CodeBehind, to add the grid some controls.

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 ...