This is a migrated thread and some comments may be shown as answers.

RadTreeView IsVirtualizing not rendering all tree nodes

2 Answers 128 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Sergio
Top achievements
Rank 1
Sergio asked on 02 Apr 2015, 06:36 PM
I'm having an issue when I expand a node with many children only the first 20 or so out of 1500 are rendered on screen.

XAML CODE

<UserControl.Resources>
        <telerik:HierarchicalDataTemplate x:Key="ItemTemplate" ItemsSource="{Binding Children}">
            <StackPanel Orientation="Horizontal">               
                <TextBlock Text="{Binding Node}" Foreground="Black" FontWeight="Bold" FontSize="15" />
            </StackPanel>
        </telerik:HierarchicalDataTemplate>
    </UserControl.Resources>
...

<telerik:RadTreeView x:Name="RadTreeViewTest" Margin="5" IsVirtualizing="True" MaxHeight="300"
                             ItemsSource="{Binding}"
                             IsExpandOnSingleClickEnabled="True"
                             IsExpandOnDblClickEnabled="False"
                             ItemTemplate="{StaticResource ItemTemplate}"
                             IsLoadOnDemandEnabled="True"
                             LoadOnDemand="RadTreeViewItem_OnLoadOnDemand">        
        </telerik:RadTreeView>


Codebehind for the ondemand fetch

private void RadTreeViewItem_OnLoadOnDemand(object sender, RadRoutedEventArgs e)
        {
            RadTreeViewItem clickedItem = e.OriginalSource as RadTreeViewItem;
            VirtualTreeItem item = clickedItem.Item as VirtualTreeItem;

            for (int i = 0; i < 1500; i++)
            {
                item.Children.Add(new VirtualTreeItem(i.ToString(), ("Item" + i), i.ToString(),item));
            }

            clickedItem.IsExpanded = true;
            clickedItem.BringIntoView();
            clickedItem.IsLoadOnDemandEnabled = false;
        }



Any idea why all my items aren't rendering or how to fix it?








2 Answers, 1 is accepted

Sort by
0
Sergio
Top achievements
Rank 1
answered on 02 Apr 2015, 09:10 PM
Just noticed that if I reload the RadTreeView again with all the items already in memory from the previous onDemand calls the virtualization works perfectly fine. Do I need to do something for the tree to update correctly with onDemand so virtualization will recognize all the items?
0
Accepted
Petar Mladenov
Telerik team
answered on 06 Apr 2015, 10:37 AM
Hello Sergio,

As discussed privately, changing  the root and child collection types from Lists to ObservableCollections will resolve this scenario. Please let us know if this works correctly on your side.

Regards,
Petar Mladenov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
TreeView
Asked by
Sergio
Top achievements
Rank 1
Answers by
Sergio
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or