使用telerik radtreeview按需加载

时间:2022-01-24 07:19:54

I build the Radtreeview with child items, using the load on demand event to load the child items and it works for fine.

我用子项目构建Radtreeview,使用按需加载事件来加载子项目,它可以正常工作。

The problem here is for every child item there is expand sign but there is a point there are no child items for a parent, in that case for the child items I don't want show the expand sign. How can I achieve this ?

这里的问题是每个子项都有扩展符号,但有一点是父项没有子项,在这种情况下,我不想显示扩展符号的子项。我怎样才能做到这一点?

1 个解决方案

#1


6  

I found the answer there is a property called IsLoadOnDemandEnabled and set this property to false on ItemPrepared event.

我发现答案有一个名为IsLoadOnDemandEnabled的属性,并在ItemPrepared事件中将此属性设置为false。

                  <telerik:RadTreeView  x:Name="radTreeView" 
                             IsExpandOnSingleClickEnabled="True"
                             IsLoadOnDemandEnabled="true" 
                             LoadOnDemand="RadTreeView_LoadOnDemand"
                            ItemPrepared="radTreeView_ItemPrepared"
                            ItemsSource="{Binding TreeViewSource,Mode=OneWay}" 
                         ItemTemplate="{StaticResource ParentTemplate}"
                         />

and in the xaml.cs

并在xaml.cs中

    private void radTreeView_ItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)
    {
        // get a reference to the item that has been selected
        RadTreeViewItem preparedItem = e.PreparedItem as RadTreeViewItem;
            preparedItem.IsLoadOnDemandEnabled = false;
    }

for reference http://www.telerik.com/help/wpf/radtreeview-features-load-on-demand.html

供参考http://www.telerik.com/help/wpf/radtreeview-features-load-on-demand.html

#1


6  

I found the answer there is a property called IsLoadOnDemandEnabled and set this property to false on ItemPrepared event.

我发现答案有一个名为IsLoadOnDemandEnabled的属性,并在ItemPrepared事件中将此属性设置为false。

                  <telerik:RadTreeView  x:Name="radTreeView" 
                             IsExpandOnSingleClickEnabled="True"
                             IsLoadOnDemandEnabled="true" 
                             LoadOnDemand="RadTreeView_LoadOnDemand"
                            ItemPrepared="radTreeView_ItemPrepared"
                            ItemsSource="{Binding TreeViewSource,Mode=OneWay}" 
                         ItemTemplate="{StaticResource ParentTemplate}"
                         />

and in the xaml.cs

并在xaml.cs中

    private void radTreeView_ItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)
    {
        // get a reference to the item that has been selected
        RadTreeViewItem preparedItem = e.PreparedItem as RadTreeViewItem;
            preparedItem.IsLoadOnDemandEnabled = false;
    }

for reference http://www.telerik.com/help/wpf/radtreeview-features-load-on-demand.html

供参考http://www.telerik.com/help/wpf/radtreeview-features-load-on-demand.html