This is a migrated thread and some comments may be shown as answers.

TreeViewItem.ParentTreeView and ParentItem is null

1 Answer 85 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kelley Wong
Top achievements
Rank 1
Kelley Wong asked on 17 Aug 2010, 07:39 AM
I build the treeview code behind ,when i binding the data to the treeview , i find the child treeviewitem is checked while the parent treeviewitem is not .so i debug it and i find the TreeViewItem.ParentTreeView and ParentItem is null ,that is why the issue occurs.
the treeview porperties are set as follows:
IsTriStateMode="True"
IsLineEnabled="True"
ItemsOptionListType="CheckList"
IsOptionElementsEnabled="True"

could you tell me why TreeViewItem.ParentTreeView and ParentItem is null?
thank you

1 Answer, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 18 Aug 2010, 05:01 PM
Hello Kelley Wong,


I created a sample project illustrating what is happening.

Generally item's ParentItem and ParentTreeView are null when the item is not created and showed by the tree view. Meaning that when you try to get the item's ParentItem or ParentTreeView when the item is not visible i.e. his parent is not expanded then these values will be null. This is expected behavior because the tree view is virtualized and only required items at the moment are created. When some item is expanded, it's children are created and initialized. When children are properly initialized then the parent properties are set correctly.

Please take a look at the attached project and experiment with the check button. Try these scenarios:
1. Create Tree --> Check Tree --> look at the VS output --> parent properties are null.
2. Create Tree --> Expand Item 1 --> Check Tree --> look at the VS output --> parent properties are correct.


Sincerely yours,
Hristo Milyakov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Kelley Wong
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or