WPF TreeView and Checkbox

后端 未结 3 1010
南旧
南旧 2021-02-10 06:30

How would someone go about adding check boxes to only the children of a tree view in XAML? My goal is to have a tree view where the parent is just a text block and all the chil

3条回答
  •  深忆病人
    2021-02-10 06:49

    Why don't you just do it in code? Like this:

            TreeViewItem newItem = new TreeViewItem()
            {
                Header = "One"
            };
    
            treeViewObjects.Items.Add(newItem);
    
            TreeViewItem newItem1 = new TreeViewItem()
            {
                Header = new CheckBox()
                {
                    Content = "Two"
                }
            };
            newItem.Items.Add(newItem1);
    

提交回复
热议问题