Treeview with checkboxes? RRS feed

  • Question

  • How can I do a treeview with checkboxes?
    Monday, March 1, 2010 3:23 PM

All replies

  • Hi GClaes

    This is small example to show how to add checkBox in treeView,
    you have a treeView with a button to add a checkBox when clicked, this for adding on runtime, but if you want to add on implementing time to be static you can drag the checkBoxs and drop on the treeView control

    I hope the example to help you:

    Xaml Code:

        Width="300" Height="480">

        <Grid x:Name="LayoutRoot">
            <TreeView HorizontalAlignment="Center" x:Name="tvSampleTree" Width="250" Margin="0,3.5,8,38.5"/>
            <Button HorizontalAlignment="Center" Margin="0,0,21,4.5" VerticalAlignment="Bottom" Width="136" Height="30" Content="Add New CheckBox" Click="btnClick"/>

    Button Click Event:

    private void btnClick(object sender, System.Windows.RoutedEventArgs e)
                // TODO: Add event handler implementation here.
                TreeViewItem RootLevel = new TreeViewItem();
                RootLevel.Header = "Root Level";
                //Create the CheckBox Child
                CheckBox FirstChild= new CheckBox();
                FirstChild.Content="I'm CheckBox Child";


    Mohamed Sabry
    • Proposed as answer by Mohamed Sabry Monday, March 1, 2010 3:54 PM
    Monday, March 1, 2010 3:52 PM