在Telerik for silverlight控件radtreeview中如何通过路径得到节点(转载)
页面
<telerik:RadTreeView Margin="8" x:Name="radTreeView" SelectionChanged="radTreeView_SelectionChanged" Loaded="radTreeView_Loaded">
<telerik:RadTreeViewItem Header="Sport Categories">
<telerik:RadTreeViewItem Header="Football">
<telerik:RadTreeViewItem Header="Futsal"/>
<telerik:RadTreeViewItem Header="Soccer"/>
</telerik:RadTreeViewItem>
<telerik:RadTreeViewItem Header="Tennis">
<telerik:RadTreeViewItem Header="Table Tennis"/>
</telerik:RadTreeViewItem>
<telerik:RadTreeViewItem Header="Cycling">
<telerik:RadTreeViewItem Header="Road Cycling"/>
<telerik:RadTreeViewItem Header="Indoor Cycling"/>
<telerik:RadTreeViewItem Header="Mountain Bike"/>
</telerik:RadTreeViewItem>
</telerik:RadTreeViewItem>
</telerik:RadTreeView>
当页面完全载入后执行loaded命令
private void radTreeView_Loaded(object sender, RoutedEventArgs e)
{
GetTreeViewItemByPath();
}
定义GetTreeViewByPath方法的逻辑
private void GetTreeViewItemByPath()
{
string path = "Sport Categories|Football|Soccer";
radTreeView.PathSeparator = "|";
RadTreeViewItem targetItem = radTreeView.GetItemByPath( path );
}
系统会根据定义的路径(path)展开树并找到节点(如图)
![在Telerik for silverlight控件radtreeview中如何通过路径得到节点 - qiuguangchun - sandea的个人主页](http://hi.csdn.net/attachment/201108/19/0_1313719821Z3S4.gif)