https://code.msdn.microsoft.com/windowsdesktop/Changing-selection-in-a-6a6242c8#content The attached code works well at .NET 3.5 . However at .NET 4.0 , it appears the same problem.
<TreeView ItemsSource="{Binding}" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard"> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Parts}"> <TextBlock Text="{Binding Name}"/> <HierarchicalDataTemplate.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding}"/> </DataTemplate> </HierarchicalDataTemplate.ItemTemplate> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); IList<Car> list = new List<Car>(); for (int i = 0; i < 5000; i ++) { list.Add(new Car() {Name = "test1" + i}); } foreach (var car in list) { car.Parts = new List<string>(); for (int i = 0; i < 500; i++) { car.Parts.Add("asdf" + i); } } this.DataContext = list; } } public class Car { public string Name { get; set; } public List<string> Parts { get; set; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)