views:

19

answers:

1

Hello colleagues. I want bind my treeview. There are a lot of samples binding treeview by object, which contains children collection. I've got domain having just Parent pointer.

   public class Service : BaseDomain
   {
        public virtual string Name { get; set; }
        public virtual string Description { get; set; }
        public virtual Service Parent { get; set; }
   }

Can I bind collection of this objects to my treeView. Thanks

A: 

It's not possible with HierarchicalDataTemplate, but you could create custom convertedr for ItemsSource binding. In general case converting such structure to tree might be resource intensive task (particularly it requires that treeview grabs all your data before displaying tree root).

olegz