Given a RadTreeViewItem, I want to expand all if it's descendants. I receive the first RadTreeViewItem via an attached behavior:
private void OnLoaded(object sender, RoutedEventArgs e)
RadTreeViewItem tvi = AssociatedObject;
after doing some checks I call tvi.IsExpanded = True and tvi.IsSelected = True;
This gets my tree opened up to the desired node. Now I want to expand all of it's children so the user doesn't have to open up each branch by hand.
private void ExpandChildren(RadTreeViewItem tvItem)
//var container = tvItem.ItemContainerGenerator.IndexFromContainer();
var tvi = tvItem;
foreach (RadTreeViewItem item in tvi.Items)
var kid = tvi.ParentTreeView.ContainerFromItemRecursive(item);
kid.IsExpanded = true;
However, this function blows up on line 6 complaining that the item cannot be converted from the value (in my case an app specific class) type to a RadTreeViewItem. I tried using ContainerFromItemRecursive, but it always seems to return null. How to convert a tvi.Items[n] to a RadTreeViewItem that I can mark IsExpanded = true?
This seems like this shouldn't be that hard.
Can someone please point me in the right direction?
Thanks ... Ed