Thanks
Rob
6 Answers, 1 is accepted
Just set the IsExpanded property to true of that RadTreeViewItem and you will have its child nodes displayed.
If you need to expand recursively - use the ExpandAll() method of the RadTreeViewItem (or on the RadTreeView if you want all the nodes expanded).
Greetings,
Valentin.Stoychev
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Could you please elaborate more on your scenario and especially what you wish to achieve? This way we could be much better able to assist you and advice you. Since this a very old post, it will be also important to let us know the RadControl's version that you use. Thank you in advance.
All the best,Petar Mladenov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

i use the Load On Demand mode of RadTreeView and i want to expand the root node programmetically after i added the root node on Page_Load for example. the obvious way is that the Expand Property of the node be true, but it's doesn't work.
so how can i expand the node programmetically on LoadOnDemand mode?
thanks for advance.
You need to expand the root inside a dispatcher. Please consider the following approach.
<
telerik:RadTreeView
x:Name
=
"treeView1"
LoadOnDemand
=
"treeView1_LoadOnDemand"
IsLoadOnDemandEnabled
=
"True"
/>
public
partial
class
MainPage : UserControl
{
public
MainPage()
{
InitializeComponent();
this
.Loaded +=
new
RoutedEventHandler(MainPage_Loaded);
}
void
MainPage_Loaded(
object
sender, RoutedEventArgs e)
{
RadTreeViewItem root =
new
RadTreeViewItem();
root.Header =
"Root"
;
this
.treeView1.Items.Add(root);
this
.Dispatcher.BeginInvoke(() =>
{
root.IsExpanded =
true
;
});
}
private
void
treeView1_LoadOnDemand(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
RadTreeViewItem parent = e.OriginalSource
as
RadTreeViewItem;
for
(
int
i = 0; i < 5; i++)
{
RadTreeViewItem item =
new
RadTreeViewItem();
item.Header =
"Item "
+ i;
parent.Items.Add(item);
}
parent.IsLoadingOnDemand =
false
;
}
}
Give it a try and let me know if it helps.
Greetings,
Kiril Stanoev
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
