Hi,
I want to view in xamtreeview regular class.
Lets take for example these class:
public class A
{
public ObservableCollection<B> Items { get; set; }
}
public class B
public class C { get; set; }
public class D { get; set; }
public class IgnoreClass { get; set; }
public class C
public ObservalbeCollection<E> Items { get; set; }
inside each B class there should be 2 fields,
the Fisrt is C - with Items inside it ('Items' field in C class),
and the Second is just an item (D class), with no childrens.
How can I Bind the user controll to this type of class (class A), and by adding Nodes Layouts - show this tree structure.
Thanks,
Guy.
I am just checking your progress on the issue.
If you have any other questions on the matter, please feel free to ask.
You need to hook up to the CollectionChanged event of the original collection and when it changes you'll need to update the TreeClass.List1 collection. And since the binding collection is implementing INotifyCollectionCollection changed interface the DataTree will get updated.
I couldn't quite catch where you going with your second question. A NodeLayout is something like a data template instructing the xamDataTree items of which type should it look for when it is creating its hierarchy and eventually how to present the nodes found in the ItemsSource. So I don't think you could create a DataTreeItem and then set the layout.
Regards,
one last thing
My solution is to create a special class to "bind" the original class in the XamDataTree,
but when I want to bind collections (observable) , when I add item to the original collection, the xamdatatree isn't updated.
for example:
TreeClass.List1 = OriginalCLass.List1
the tree in gui isn't update according to the original list.
And another thing, if I create a DataTreeItem instead of a special class, to bind my things,
How can I set the layouts of each item? in the code behind when I create the items?
Thanks!
Unfortunately, XamDataTree does not support such capabilities to present a class property as a node. XamDataTree looks through the properties of a class that that are collections of some sort and use them to created the child nodes on the next level of the tree.
So your options are presenting the values of Value1,Value2 and the items in the Collection1 in a single collection so they could be on one level and look like the tree you described above.
Hope this helps,
Thanks for the NodeLayout example code, but except this , I want to show in my tree also properties that are not a collection.
for example - If A has a collection of B, and B has properties Value1,Value2,Collection1,Collection2 then the tree should look like:
A
-B
--Value1
--Value2
--Collection1
---I1
---..
--Collection2
---J1
etc.