wpf manually generate TreeViewItem container
- by viky
I am creating a TreeView at runtime. It has several nodes(TreeViewItem), each one having a name. Initially it is collapsed. A separate comboBox displays Names of all TreeViewItem. I have to highlight a TreeViewItem based on the Name selected. I am using a recursive function and gets the TreeViewItem container like this:
if (parent.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
continue;
TreeViewItem container = parent.ItemContainerGenerator.ContainerFromItem(child).As<TreeViewItem>();
but it is
parent.ItemContainerGenerator.Status = GeneratorStatus.NotStarted
for all the collapsed items. How can I generate containers for them manually(Without expanding them)?