I generate my row like this:
Telerik.Windows.Controls.TreeListView.
TreeListViewRow row = (Telerik.Windows.Controls.TreeListView.TreeListViewRow)radTreeListView1.ItemContainerGenerator.ContainerFromItem(radTreeListView1.SelectedItem);
If I see parent row on the screen, I can reach row.ParentRow but if I don't see parent row on the screen
row.ParentRow is null.
How can I handle this?
Thanks.
7 Answers, 1 is accepted
That would be the expected behavior due to the fact that the virtualization of the RadTreeListView is turned on by default. This means that only the visible visual elements are created and on scrolling they are recycled and reused. Generally, the recommended way is to work directly with the underlying data item (by Items collection for example).
May you share what is the scenario that you want to accomplish ? Why do you need to work with the rows, instead of the items ?
Maya
the Telerik team

Thank you for your reply.
I am not sure how I can take the parent item from underlying data.
I can reach child items like this (MyClass)treelistView1.SelectedItem).Items, But how can I reach parent Item? Should I have a reference back to its parent class?
Thanks.
Basically, you may use the connection between the parent item and its children. May you provide a bit more details what is the implementation of the two business objects ? Do you have an exposed property connecting them ?
Maya
the Telerik team

Hi,
My implementation is similar sample classes below.
public class Level0_0
{
public string Level0{ get; set; }
public ObservableCollection<Level1> Items { get; set; }
}
public class Level0_1
{
public string Level1{ get; set; }
public ObservableCollection<Level2> Items { get; set; }
public Level0 ParentItem { get; set; }
}
public class Level0_2
{
public string Level2{ get; set; }
public ObservableCollection<Level3> Items { get; set; }
public Level1 ParentItem { get; set; }
}
My problem is Level0_2 is shared object. For example Level1_1 object also have Level0_2 object. So I overrite ParentItem.
I have to take the root element of the selected item. Is there any way to turn off virtualization?
Thanks
Based on the code-snippet provided, I get the impression that you may use the ParentItem property of the business object. Am I right or am I missing something ?
Considering turning off the virtualization, you may set the EnableColumnVirtualization/ EnableRowVirtualization properties of the RadGridView to false. However, if you handle a lot of data, this might lead to some performance issues.
Maya
the Telerik team

Yes, I can use ParentItem. But my problem occurs when I used shared objects as I mentioned. For example I have shared static object Level0_2 then it has two parents:Level0_0 and Level1_0. When I select the Level0_2 item I can't use ParentItem property. Because of this I want to use ParentRow.
Level0_0
Level0_1
Level0_2
Level1_0
Level1_1
Level0_2
The only way for getting the parent item to handle it at data level. As the structure of the TreeListView is a flat one, no actual hierarchy at UI level is created. Thus, if you want to find the parent item from a child one, you need to have a single parent and find it through the corresponding property.
Maya
the Telerik team