public void ExpandAll() { foreach (Group grp in items.Children) { foreach (GraphicObject go in grp.Children) { Expandable exp = go as Expandable; if (exp == null) { continue; } TreeView subTV = exp.FindByName("List") as TreeView; if (subTV == null) { continue; } EventHandler handler = null; handler = delegate(object sender, EventArgs e) { TreeView tv = sender as TreeView; tv.Loaded -= handler; tv.ExpandAll(); }; subTV.Loaded += handler; exp.IsExpanded = true; } } }
protected void loadItem(object o, Group page, string _dataTest) { if (o == null) //TODO:surely a threading sync problem { return; } GraphicObject g = null; ItemTemplate iTemp = null; Type dataType = o.GetType(); string itempKey = dataType.FullName; if (_dataTest != "TypeOf") { itempKey = getItempKey(dataType, o, _dataTest); } if (ItemTemplates.ContainsKey(itempKey)) { iTemp = ItemTemplates [itempKey]; } else { foreach (string it in ItemTemplates.Keys) { Type t = CompilerServices.tryGetType(it); if (t == null) { continue; } if (t.IsAssignableFrom(dataType)) //TODO:types could be cached { iTemp = ItemTemplates [it]; break; } } if (iTemp == null) { iTemp = ItemTemplates ["default"]; } } lock (IFace.LayoutMutex) { g = iTemp.CreateInstance(); #if DESIGN_MODE g.design_isTGItem = true; #endif page.AddChild(g); // if (isPaged) g.LogicalParent = this; g.MouseDown += itemClick; } if (iTemp.Expand != null && g is Expandable) { Expandable e = g as Expandable; e.Expand += iTemp.Expand; e.GetIsExpandable = iTemp.HasSubItems; } g.DataSource = o; }