1 private void ExpandAllFolder(GsTreeListViewItem aItem) 2 { 3 if (aItem == null) return; 4 CPlanContentAndOrder ItemPlan = aItem.Header as CPlanContentAndOrder; 5 if (ItemPlan.iType != (int)TPlanNodeType.EFolder) return; 6 aItem.IsExpanded = true; 7 if (aItem.ItemContainerGenerator.Status != System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated) 8 { 9 //生成子节点 10 aItem.ItemContainerGenerator.StatusChanged += new EventHandler(delegate 11 { 12 if (aItem.ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated) 13 { 14 for (int i = 0; i < aItem.Items.Count; i++) 15 { 16 GsTreeListViewItem item = aItem.ItemContainerGenerator.ContainerFromIndex(i) as GsTreeListViewItem; 17 ExpandAllFolder(item); 18 } 19 } 20 }); 21 } 22 else 23 { 24 for (int i = 0; i < aItem.Items.Count; i++) 25 { 26 GsTreeListViewItem item = aItem.ItemContainerGenerator.ContainerFromIndex(i) as GsTreeListViewItem; 27 ExpandAllFolder(item); 28 } 29 } 30 }