代码如下 [csharp] List<IrrlSysFun> datas; public CWRoleRight() { InitializeComponent() BLLSysFunBLLFindAll(list => { datas = listToList() LoadTree(treeViewItems ) }) } private void LoadTree(ItemCollection itemCollection int p) { var subList = datasWhere(d => dpid == p)ToList() foreach (var item in subList) { TreeViewItem tv = new TreeViewItem() StackPanel sp = new StackPanel() CheckBox cb = new CheckBox() cbChecked += new RoutedEventHandler(cb_Checked) cbContent = itemnodeText; cbTag = tv; spChildrenAdd(cb) tvHeader = sp; itemCollectionAdd(tv) tvIsExpanded = true; LoadTree(tvItems itemnodeid) } } 界面效果 |