I am trying to bind the UltraTree using a Linq extension which return a hirarchical structure.
Unfortunately the tree is displaying the data in a bizarre way ...
The structure is
Object - Name -IList<Object>
Where of course for each IList<Object> there can be an additional list of childs
The treeview shows me only the 4 nodes in the root and an additional column containing the full structure of the childs displayed using the toString() method of the IList<T>
How it works this control?
Just to clarify this is the code I am using:
A hierarchy structure of objects:
public sealed class WorkflowLogHierarchy { public WorkflowLogContract Log { get; set; } public IList Childs { get; set; } }
Then I have created a simple extension which create the correct tree structure
public static IList GetJobHierarchy(this IList allLogs, WorkflowLogContract parentLog) { Guid? parentUid = null; if (parentLog != null) { parentUid = parentLog.UniqueId; } var childLogs = allLogs.Where(x => x.ParentUniqueId == parentUid); List hierarchy = new List(); foreach (var childLog in childLogs) { hierarchy.Add(new WorkflowLogHierarchy { Log = childLog, Childs = GetJobHierarchy(allLogs, childLog) }); } return hierarchy; }
This code works because if I bind this structure to a WPF treeview or a simple WInFOrm treeview I get the expected result. On you control I just get a weird and bizarre result so it means that your control has some constraint on the data it can displays. Can you explain me how I should structure the data for your control? Thank you
Hi,
This really has nothing to do with the tree. The DotNet BindingManager determines the data structure. In my experience, it will not recognize IList (or any interface type) as a list for binding.
If you intend to use DataBinding, you should use BindingList<T>, instead. You can also use List<T>, but this will provide limited functionality, as the List<T> is not really made for DataBinding.