Yes, the WPF treeview is known to be a bit slow, so don't add all the elements to the treeview.
Assuming you're using a view model, you could perform lazy initialization of the 'Children' collection for each node.
Something like:
ObservableCollection<node> children;
public ObservableCollection<node> Children
{
get
{
if(children == null)
{
LoadChildren();
}
return children;
}
}
</node></node>
where LoadChildren(); obviously must initialize and populate the children collection.
You will also need to declare a HierarchicalDataTemplate for the Node class:
<HierarchicalDataTemplate x:Key="NodeTemplate" ItemsSource="{Binding Children}">
<StackPanel>
<TextBlock Text="{Binding Path=Name}" />
</StackPanel>
</HierarchicalDataTemplate>
While not a final fix for performance related to the WPF treeview, it's better than initially populating the tree with all the items. You can also expand on this method by performing the
LoadChildren();
asynchronously in a separate thread.
Best regards
Espen Harlinn