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
610
ParentItem Bug
posted

Hello,

  I think I found a bug with the ParentItem property of a node.  When a node gets added to another, the child node's ParentItem node is always null.  I think based on the documentation, this should be the reference to the parent node.  Is there any work around to get the parent node of a child?  Thanks.

 

Infragistics.Controls.Menus.XamTreeItem ndeRoot = new Infragistics.Controls.Menus.XamTreeItem();
ndeRoot.Header = "RootItem";

Infragistics.Controls.Menus.XamTreeItem ndeChild = new Infragistics.Controls.Menus.XamTreeItem();
ndeChild.Header = "ChildItem";
ndeRoot.Items.Add(ndeChild);

this.XamTree1.Items.Add(ndeRoot);

if (ndeChild.ParentItem == null) {
 System.Windows.MessageBox.Show("Parent Null");
} else {
 System.Windows.MessageBox.Show("Parent Not Null");
}

Parents
No Data
Reply
  • 40030
    Offline posted

    Hi, 

    This isn't actually a bug. ParentItem refers to the Data object that owns the child. So if you were bound, it would refer to the data objects that owns the child. In the case where you're adding controls directly to the control, then it refers to the control. However, parent associations only occur when the control is actually added to the visualTree, So after the parent is expanded, since the child added to the Items collection could be anything, the only way to know if the XamTreeItem actually exists is once its actually invoked naturally through the ItemsControl framework. 

    -SteveZ

Children