Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
XamDataTree does not respect ObservableCollections
posted

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

Parents
No Data
Reply
  • 12875
    posted

    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. 

     

    Wpf_xamDataTree_NodeLayout.zip
Children