Ejemplo n.º 1
0
        /// <summary>
        /// 数据绑定
        /// </summary>
        private void TvTestDataBind()
        {
            IList <MultiSelectorViewModel> treeList = new List <MultiSelectorViewModel>();

            for (int i = 0; i < 5; i++)
            {
                MultiSelectorViewModel tree = new MultiSelectorViewModel();
                tree.Id         = i.ToString();
                tree.Name       = "Test" + i;
                tree.IsExpanded = true;
                for (int j = 0; j < 5; j++)
                {
                    MultiSelectorViewModel child = new MultiSelectorViewModel();
                    child.Id     = i + "-" + j;
                    child.Name   = "Test" + child.Id;
                    child.Parent = tree;
                    if (j % 2 == 0)
                    {
                        MultiSelectorViewModel childsChild = new MultiSelectorViewModel();
                        childsChild.Id     = i + "-" + j + "-" + j;
                        childsChild.Name   = "Test" + childsChild.Id;
                        childsChild.Parent = child;
                        child.Children.Add(childsChild);
                    }
                    tree.Children.Add(child);
                }
                treeList.Add(tree);
            }

            //设置数据
            multiSelector.ItemsSourceData = treeList;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 选中所有子项菜单事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void menuSelectAllChild_Click(object sender, RoutedEventArgs e)
 {
     if (tvZsmTree.SelectedItem != null)
     {
         MultiSelectorViewModel tree = (MultiSelectorViewModel)tvZsmTree.SelectedItem;
         tree.IsChecked = true;
         tree.SetChildrenChecked(true);
     }
 }