I am using a radtreeview and i want to make some treeviewitems checked while the tree is loading(in the tree_loaded event).
The problem is that I couldn't retrieve the treeviewitems. I used itemcontainergenerator, but its status is always showing as 'Not Started'. I tried by expanding the tree .Also tried using dispatcher. But still not working. Could anyone help me?
4 Answers, 1 is accepted
Please check this help article:
the Telerik team
thanks for your reply. i tried the same example code as given below
private void GetContainers()
// gets all nodes from the TreeView
Collection<RadTreeViewItem> allTreeContainers = GetAllItemContainers(this.itemSourceTree);
// gets all nodes (recursively) for the first node
RadTreeViewItem firstNode = this.itemSourceTree.ItemContainerGenerator.ContainerFromIndex(0) as RadTreeViewItem;
if (firstNode != null)
Collection<RadTreeViewItem> firstNodeContainers = GetAllItemContainers(firstNode);
private Collection<RadTreeViewItem> GetAllItemContainers(Telerik.Windows.Controls.ItemsControl itemsControl)
Collection<RadTreeViewItem> allItems = new Collection<RadTreeViewItem>();
for (int i = 0; i < itemsControl.Items.Count; i++)
// try to get the item Container
RadTreeViewItem childItemContainer = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as RadTreeViewItem;
// the item container maybe null if it is still not generated from the runtime
if (childItemContainer != null)
Collection<RadTreeViewItem> childItems = GetAllItemContainers(childItemContainer);
foreach (RadTreeViewItem childItem in childItems)
private void itemSourceTree_Loaded(object sender,RoutedEventArgs e)
But it is also not working. I am getting "childItemContainer" always null. What should i do?
If the item is not expanded its children are not prepared from the silverlight framework - e.g. they do not exist. This is why you get null for the item. You need to use the ItemPrepared event in your case. Please check this forum post:
the Telerik team
Thanks for your immediate reply. In itemprepared event, i am getting each treeviewitem. So i think that will solve my problem.