I've created a hierarchical data structure using ObservableCollection<T> where each item contains a public ObservableCollection<T> to connect to the next node. The data structure is similar to the one in the DataUtil class which is in your DataTreeBinding example.
The problem is that only the root node gets displayed and I don't see an Expand Icon where I know there are sub-nodes in the data. What is the requirement in order to get the XamDataTree to recognize there are sub-nodes?
I'm binding in code like this:this.MyTree.DataContext = m_menuData;this.MyTree.ItemsSource = m_menuData.Centers;where m_menuData is the object that contains the data and m_menuData.Centersis the ObservableCollection<T> that contains the data hierarchy.
That helps. Thank you.
Joe
Hi,
The process of assigning a layout is really complex - so if we start from the root, the tree examines the items from the data source and tries to match with a NodeLayout defined as global layout, by the TargetTypeName.
Also, each item's IEnumerable properties are checked and matched against NodeLayout-s Key property, if a match is found the the layout for the child level is assigned. Otherwise, the tree falls back to matching the item type of that IEnumerable to TargetTypeName property of the NodeLayout-s.
The process goes further for all levels.
Note: the process described is for the case with NodeLayout-s defined in the GlobalNodeLayouts collection.
I hope that clarifies things a bit.
Yes, that was one of my questions and I'm sure given time I'll see the light and understand it all. But right now, unfortunately due to time constraints, I have a working tree using XamTree. I will have to pursue this approach later. I would much prefer to use databinding.
One thing I'm still failing to understand is the role played by the Key value (as in Key="CategoryLayout"). Could you elaborate on your statement: "...the sample is working because obviously the XamDataTree is able to match the data (? spelling): I assume data was meant) by the specified key value." Based on the sample, "DataTreeBinging" solution,which shows Key="CategoryLayout" and TargetTypeName="Category", I had the impression that TargetTypeName is used to match up with the data. Is that a wrong assumption on my part. If so, what role does TargetTypeName play?
Thanks again for your help!
Yes, you are right - the ITestData in the sample is wrong, sorry about that. The actual value should have been IChildTestData and the sample is working because obviously the XamDataTree is able to match the date by the specified Key value.
As you can see, the IChildTestData is used as ObservableCollection<T> type parameter, so it is just as in your case when you have a base class specified and that's what I tried to demonstrate - wasn't that one of your questions?
What else do you think is not addressed by the sample?
HTH,
Thanks, but I don't understand your sample and how it relates to my problem. Perhaps I haven't explained my problem well enough or maybe your sample does apply and I just don't get it.
One thing about your sample that really baffles me is that in your XAML you have this:TargetTypeName="ITestData", In the solution there is no interface named "ITestData". There is "IChildTestData" but not "ITestData". So, how is this working? I have run the application so I know it does work.
I think for now, I'm going to forgo trying to do this with databinding and revert back to using XamTree where I can explicitly create the tree nodes in code.
I would appreciate your addressing my question above about "ITestData". I apparently don't understand C# and XamDataTree as well as I should.
Thank you very much for your assistance.