Hi, your XamDataTree does not work as expected. This code doesn't show group2 under group1 --- ObservableCollection<object> items = new ObservableCollection<object> (); var g1 = new AttributeGroupItem() {Name = "Level1"}; var g2 = new AttributeGroupItem() {Name = "Level2"}; g1.Items.Add (new AttributeItem () { Name = "L1 Child" }); g2.Items.Add (new AttributeItem () { Name = "L2 Child" }); g1.Items.Add (g2); items.Add (g1); this.xamDataTree1.ItemsSource = items; --- But that code does! --- ObservableCollection<object> items = new ObservableCollection<object> (); var g1 = new AttributeGroupItem() {Name = "Level1"}; var g2 = new AttributeGroupItem() {Name = "Level2"}; g1.Items.Add (g2); g1.Items.Add (new AttributeItem () { Name = "L1 Child" }); g2.Items.Add (new AttributeItem () { Name = "L2 Child" }); items.Add (g1); this.xamDataTree1.ItemsSource = items; --- My goal is to display Nodes recursively. Regards Benjamin
Hi, your XamDataTree does not work as expected.
This code doesn't show group2 under group1
--- ObservableCollection<object> items = new ObservableCollection<object> (); var g1 = new AttributeGroupItem() {Name = "Level1"}; var g2 = new AttributeGroupItem() {Name = "Level2"}; g1.Items.Add (new AttributeItem () { Name = "L1 Child" }); g2.Items.Add (new AttributeItem () { Name = "L2 Child" }); g1.Items.Add (g2); items.Add (g1); this.xamDataTree1.ItemsSource = items;
---
But that code does!
ObservableCollection<object> items = new ObservableCollection<object> (); var g1 = new AttributeGroupItem() {Name = "Level1"}; var g2 = new AttributeGroupItem() {Name = "Level2"};
g1.Items.Add (g2);
g1.Items.Add (new AttributeItem () { Name = "L1 Child" }); g2.Items.Add (new AttributeItem () { Name = "L2 Child" }); items.Add (g1); this.xamDataTree1.ItemsSource = items;
My goal is to display Nodes recursively.
Regards
Benjamin
Hi,
It’s hard for me to determine why your code isn’t working. I created a sample and created my own class definitions for AttributeGroupItem and AttributeItem and added NodeLayouts to the xaml.
Run my sample and then select which of your code snippets you want to use to load the xamDataTree. I see the same items with either code. If you can give me more detail about specifically what you are seeing and your layout design xaml that would be very helpful.
Thank you for your efforts! I didn't expect that you write a sample soloution for my problem.
In my code AttributeGroupItem derives from AttributeItem and has only one common collection of type ObservableCollection<AttributeItem> "Items". It seems that the given node layout dosn't work in that case.
If AttributeGroupItem and AttributeItem have one base class called AttributeItemBase, only one single node is shown!
I dont' know how my node layout should look like to meet my expectations.
Hi Benjamin,
No problem with the sample. I thought that might be the easier way to be sure we were on the same page.
Could you please attach your viewmodel so that I can see how you’ve constructed it?
And if I understand the GlobalNodeLayout that I gave you isn’t working to show a parent and child structure. Is that correct?
I didn’t hear back from you. Let me know if I can be of any further assistance.
sorry I've been busy this week
the hole project is attached to this post
maybee you can found out what's wrong with my code
thx
benjamin
I’m going over your sample and also looking for information about handling recursive data for the xamDataTree.
When I run your sample I see parent and first level child nodes. However, when you are adding the AttributeGroup within the child it doesn’t appear to be recognizing that it should be parent level to the subsequent Attribute items.
I will post back here when I have more information.
I believe the issue with your recursive data design is caused by the generic collection type being used to determine the NodeLayout for a level rather than using the type of the individual data item.
You could move the collection down in some way or make the collections all AttributeGroups (your derived class).
Let me know if you have further questions.
I was wondering if you needed any further help with this question.
If so, please feel free to contact me.