wpf manually generate TreeViewItem container
Posted
by viky
on Stack Overflow
See other posts from Stack Overflow
or by viky
Published on 2010-04-22T07:13:16Z
Indexed on
2010/04/22
7:43 UTC
Read the original article
Hit count: 385
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)?
© Stack Overflow or respective owner