Click here to Skip to main content
16,008,183 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
artwallacex3-Apr-08 6:06
artwallacex3-Apr-08 6:06 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
User 2710093-Apr-08 6:10
User 2710093-Apr-08 6:10 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? [modified] Pin
artwallacex3-Apr-08 6:14
artwallacex3-Apr-08 6:14 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
User 2710093-Apr-08 6:33
User 2710093-Apr-08 6:33 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
artwallacex3-Apr-08 6:47
artwallacex3-Apr-08 6:47 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
User 2710093-Apr-08 6:57
User 2710093-Apr-08 6:57 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
artwallacex3-Apr-08 7:06
artwallacex3-Apr-08 7:06 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Found the solution Pin
User 2710093-Apr-08 7:30
User 2710093-Apr-08 7:30 
I found the solution.

First put this back back the way it was.

private void button3_Click(object sender, RoutedEventArgs e)
{
    DirectoryInfo junkDir = new DirectoryInfo(@"C:\");

    TreeNode tn1 = new TreeNode("1");
    TreeNode tn2 = new TreeNode("2");
    TreeNode tn3 = new TreeNode("3");
    TreeNode tn4 = new TreeNode("4");
    TreeNode tn5 = new TreeNode("5");


    TreeNodeList.Add(tn1);

    tn1.Children.Add(tn2);
    tn1.Children.Add(tn3);

    tn2.Children.Add(tn4);
    tn2.Children.Add(tn5);

}


Modify the TreeNode class as below.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace WpfTest
{
    public class TreeNode
    {
        private string dir = "";
        private ObservableCollection<TreeNode> children = new ObservableCollection<TreeNode>();
        private List<string> files = new List<string>();

        public TreeNode(string directory)
        {
            dir = directory;
        }

        public string Dir
        {
            get { return dir; }
            set { dir = value; }
        }

        public ObservableCollection<TreeNode> Children
        {
            get { return children; }
            set { children = value; }
        }

        public List<string> Files
        {
            get { return files; }
            set { files = value; }
        }
    }
}


Your all done.

You may want to do the same to the Files collection also.

Cheers, Karl

» CodeProject 2008 MVP
» Microsoft MVP - Client App Dev

My Blog | Mole's Home Page | MVP Profile

Just a grain of sand on the worlds beaches.



modified 27-Feb-21 21:01pm.

GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Found the solution [modified] Pin
artwallacex3-Apr-08 7:42
artwallacex3-Apr-08 7:42 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Found the solution Pin
User 2710093-Apr-08 7:44
User 2710093-Apr-08 7:44 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Found the solution Pin
artwallacex3-Apr-08 8:00
artwallacex3-Apr-08 8:00 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Found the solution Pin
User 2710093-Apr-08 8:07
User 2710093-Apr-08 8:07 
QuestionTable like control to set width in percentages Pin
djdajo2-Apr-08 22:13
djdajo2-Apr-08 22:13 
GeneralRe: Table like control to set width in percentages Pin
artwallacex2-Apr-08 22:49
artwallacex2-Apr-08 22:49 
GeneralRe: Table like control to set width in percentages [modified] Pin
djdajo2-Apr-08 22:53
djdajo2-Apr-08 22:53 
GeneralSilverlight 2 (beta1) Known Issues and workarounds (if any) Pin
Michael Sync2-Apr-08 4:17
Michael Sync2-Apr-08 4:17 
GeneralRe: Silverlight 2 (beta1) Known Issues and workarounds (if any) Pin
User 2710092-Apr-08 9:35
User 2710092-Apr-08 9:35 
GeneralRe: Silverlight 2 (beta1) Known Issues and workarounds (if any) Pin
User 27100911-Apr-08 21:45
User 27100911-Apr-08 21:45 
GeneralRe: Silverlight 2 (beta1) Known Issues and workarounds (if any) Pin
Michael Sync12-Apr-08 4:18
Michael Sync12-Apr-08 4:18 
GeneralRe: Silverlight 2 (beta1) Known Issues and workarounds (if any) Pin
User 27100912-Apr-08 4:20
User 27100912-Apr-08 4:20 
GeneralDoublePost from C# Forum ... SetCooperatiionLevel with DirectX Pin
Jammer30-Mar-08 11:19
Jammer30-Mar-08 11:19 
GeneralRe: DoublePost from C# Forum ... SetCooperatiionLevel with DirectX Pin
Thomas Stockwell2-Apr-08 15:32
professionalThomas Stockwell2-Apr-08 15:32 
GeneralRe: DoublePost from C# Forum ... SetCooperatiionLevel with DirectX Pin
Jammer3-Apr-08 7:42
Jammer3-Apr-08 7:42 
GeneralDataGridView wpf style [modified] Pin
yanairon30-Mar-08 4:29
yanairon30-Mar-08 4:29 
GeneralRe: DataGridView wpf style Pin
Pete O'Hanlon30-Mar-08 8:33
mvePete O'Hanlon30-Mar-08 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.