/// <summary> /// Recursively & syncronously expand all the nodes in this subtree. /// </summary> private static void ExpandRecursive(TreeViewItem item) { if (item == null) { return; } // Expand the current item if (!item.IsExpanded) { item.SetCurrentValueInternal(IsExpandedProperty, BooleanBoxes.TrueBox); } // ApplyTemplate in order to generate the ItemsPresenter and the ItemsPanel. Note that in the // virtualizing case even if the item is marked expanded we still need to do this step in order to // regenerate the visuals because they may have been virtualized away. item.ApplyTemplate(); ItemsPresenter itemsPresenter = (ItemsPresenter)item.Template.FindName(ItemsHostPartName, item); if (itemsPresenter != null) { itemsPresenter.ApplyTemplate(); } else { item.UpdateLayout(); } VirtualizingPanel virtualizingPanel = item.ItemsHost as VirtualizingPanel; item.ItemsHost.EnsureGenerator(); for (int i = 0, count = item.Items.Count; i < count; i++) { TreeViewItem subitem; if (virtualizingPanel != null) { // We need to bring the item into view so that the container will be generated. virtualizingPanel.BringIndexIntoView(i); subitem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i); } else { subitem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i); // We dont actually need to bring this into view, but we'll do it // anyways to maintain the same behavior as with a virtualizing panel. subitem.BringIntoView(); } if (subitem != null) { ExpandRecursive(subitem); } } }
// Token: 0x06005934 RID: 22836 RVA: 0x0018A638 File Offset: 0x00188838 private static void ExpandRecursive(TreeViewItem item) { if (item == null) { return; } if (!item.IsExpanded) { item.SetCurrentValueInternal(TreeViewItem.IsExpandedProperty, BooleanBoxes.TrueBox); } item.ApplyTemplate(); ItemsPresenter itemsPresenter = (ItemsPresenter)item.Template.FindName("ItemsHost", item); if (itemsPresenter != null) { itemsPresenter.ApplyTemplate(); } else { item.UpdateLayout(); } VirtualizingPanel virtualizingPanel = item.ItemsHost as VirtualizingPanel; item.ItemsHost.EnsureGenerator(); int i = 0; int count = item.Items.Count; while (i < count) { TreeViewItem treeViewItem; if (virtualizingPanel != null) { virtualizingPanel.BringIndexIntoView(i); treeViewItem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i); } else { treeViewItem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i); treeViewItem.BringIntoView(); } if (treeViewItem != null) { TreeViewItem.ExpandRecursive(treeViewItem); } i++; } }
/// <summary> /// Recursively & syncronously expand all the nodes in this subtree. /// </summary> private static void ExpandRecursive(TreeViewItem item) { if (item == null) { return; } // Expand the current item if (!item.IsExpanded) { item.SetCurrentValueInternal(IsExpandedProperty, BooleanBoxes.TrueBox); } // ApplyTemplate in order to generate the ItemsPresenter and the ItemsPanel. Note that in the // virtualizing case even if the item is marked expanded we still need to do this step in order to // regenerate the visuals because they may have been virtualized away. item.ApplyTemplate(); ItemsPresenter itemsPresenter = (ItemsPresenter)item.Template.FindName("ItemsHost", item); if (itemsPresenter != null) { itemsPresenter.ApplyTemplate(); } else { item.UpdateLayout(); } VirtualizingPanel virtualizingPanel = item.ItemsHost as VirtualizingPanel; item.ItemsHost.EnsureGenerator(); for (int i = 0, count = item.Items.Count; i < count; i++) { TreeViewItem subitem; if (virtualizingPanel != null) { // We need to bring the item into view so that the container will be generated. virtualizingPanel.BringIndexIntoView(i); subitem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i); } else { subitem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i); // We dont actually need to bring this into view, but we'll do it // anyways to maintain the same behavior as with a virtualizing panel. subitem.BringIntoView(); } if (subitem != null) { ExpandRecursive(subitem); } } }