当前位置: 代码迷 >> Silverlight >> Silverlight 中给TreeView增添复选框
  详细解决方案

Silverlight 中给TreeView增添复选框

热度:7613   发布时间:2013-02-26 00:00:00.0
Silverlight 中给TreeView添加复选框

代码如下:

        List<IrrlSysFun> datas;        public CWRoleRight()        {            InitializeComponent();            BLL.SysFunBLL.FindAll(list => {                datas = list.ToList();                LoadTree(treeView2.Items, 0);                            });        }        private void LoadTree(ItemCollection itemCollection, int p)        {            var subList = datas.Where(d => d.pid == p).ToList();            foreach (var item in subList)            {                TreeViewItem tv = new TreeViewItem();                StackPanel sp = new StackPanel();                CheckBox cb = new CheckBox();                cb.Checked += new RoutedEventHandler(cb_Checked);                cb.Content = item.nodeText;                cb.Tag = tv;                sp.Children.Add(cb);                tv.Header = sp;                itemCollection.Add(tv);                tv.IsExpanded = true;                LoadTree(tv.Items, item.nodeid);            }        }

界面效果:


  相关解决方案