WPF TreeView and Checkbox

checkboxtreeviewwpf

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.

Best Answer

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);