I need to display a tree bound to this kind of hierarchical objects:
public class Node
{
public string Name
public List<Connector> Connector;
}
public class Connector
{
public string Name
public List<Node> TrueChildren;
}
so the actual children of a node are in the other object.
Cant make TreeView template to work with it. Seems like I need circular templates which is impossible in WPF. I feel like I am missing something obvious.
This is not necessarily circular, it is only circular if the
Connector.Childrencontain a reference to a node higher up on the current node path (and even that should be possible to handle somehow using virtualization).Normally you just need to create two
HierarchicalDataTemplatesin the resources of theTreeViewwithout anyx:Keybut theDataTypeset to the respective type.(Using
x:Typein theDataTypeis important, if you want to know why read the property reference)