I am working with WPF TreeView control. I am creating a hierarchical data structure and assigning it to ItemsSource and it will generate TreeviewItems automatically. By default I use IsExpanded of TreeViewItem to true. But in a particular case, I want to set IsExpanded property to false. So that treeview loading doesn't take time to generate all items. How can I set that in code since I don't have reference to TreeViewItem's instance at that time?
Edit:
I am looking for a way so that I can set all TreeViewItem's default behaviour in my TreeView to collapsed while doing a specific operation and set back to Expanded when this operation completes.