Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF TreeView and Checkbox

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 children are check boxes but only one child can be checked at a time. I have no problem making the whole the tree view check boxes but I am not sure how to get what I really want Any suggestions?

Thanks.

like image 558
Nathan Avatar asked Mar 07 '10 03:03

Nathan


2 Answers

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);
like image 87
Danil Avatar answered Oct 22 '22 07:10

Danil


Try this Working with Checkboxes in the WPF TreeView.

like image 7
Anonymous Avatar answered Oct 22 '22 07:10

Anonymous