Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. TreeView Data binding

TreeView Data binding

Scheduled Pinned Locked Moved WPF
wpfcsharpwcftutorialquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Joe Rozario
    wrote on last edited by
    #1

    Dear friends, i am new to wpf and i got some doubt , i have class like these

    public class FileSystem
    {
    Drive[] m_Drive;
    public Drive[] Drives
    {
    get { return m_Drive; }
    }
    }
    public class Drive
    {
    public string DriveName { get; set; }

         Directory\[\] m\_Directory;
         public Directory\[\] Directories
         {
             get { return m\_Directory; }
         }
     }
     public class Directory
     {
         public string DirectoryName { get; set; }
    
         File\[\] m\_Files;
         public File\[\] Files
         {
             get { return m\_Files; }
         }
     }
     public class File
     {
         public string FileName { get; set; }
     }
    

    now i want to represent these in treeview control, how to do that? can some one give me the XAML with (binding and explanation) Thank you Joe

    P L 2 Replies Last reply
    0
    • J Joe Rozario

      Dear friends, i am new to wpf and i got some doubt , i have class like these

      public class FileSystem
      {
      Drive[] m_Drive;
      public Drive[] Drives
      {
      get { return m_Drive; }
      }
      }
      public class Drive
      {
      public string DriveName { get; set; }

           Directory\[\] m\_Directory;
           public Directory\[\] Directories
           {
               get { return m\_Directory; }
           }
       }
       public class Directory
       {
           public string DirectoryName { get; set; }
      
           File\[\] m\_Files;
           public File\[\] Files
           {
               get { return m\_Files; }
           }
       }
       public class File
       {
           public string FileName { get; set; }
       }
      

      now i want to represent these in treeview control, how to do that? can some one give me the XAML with (binding and explanation) Thank you Joe

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Have a read (and play about) with the code that Josh Smith put together here[^].

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

      My blog | My articles | MoXAML PowerToys | Onyx

      J S 2 Replies Last reply
      0
      • P Pete OHanlon

        Have a read (and play about) with the code that Josh Smith put together here[^].

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        J Offline
        J Offline
        Joe Rozario
        wrote on last edited by
        #3

        Thank for the reply, i saw that sample , It was in MVVM patten .. i do not want anyting like that ... if i want to bind in simple way how to do that?

        P 1 Reply Last reply
        0
        • J Joe Rozario

          Thank for the reply, i saw that sample , It was in MVVM patten .. i do not want anyting like that ... if i want to bind in simple way how to do that?

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          That is the simple way. Don't try and complicate things for yourself.

          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

          As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

          My blog | My articles | MoXAML PowerToys | Onyx

          1 Reply Last reply
          0
          • J Joe Rozario

            Dear friends, i am new to wpf and i got some doubt , i have class like these

            public class FileSystem
            {
            Drive[] m_Drive;
            public Drive[] Drives
            {
            get { return m_Drive; }
            }
            }
            public class Drive
            {
            public string DriveName { get; set; }

                 Directory\[\] m\_Directory;
                 public Directory\[\] Directories
                 {
                     get { return m\_Directory; }
                 }
             }
             public class Directory
             {
                 public string DirectoryName { get; set; }
            
                 File\[\] m\_Files;
                 public File\[\] Files
                 {
                     get { return m\_Files; }
                 }
             }
             public class File
             {
                 public string FileName { get; set; }
             }
            

            now i want to represent these in treeview control, how to do that? can some one give me the XAML with (binding and explanation) Thank you Joe

            L Offline
            L Offline
            Leung Yat Chun
            wrote on last edited by
            #5

            So you want a simple way, try this one : http://karlshifflett.wordpress.com/2007/11/10/over-reaction-to-a-simple-wpf-explorer-tree/[^] I am sure it will end up even more complex though. :laugh:

            QuickZip

            1 Reply Last reply
            0
            • P Pete OHanlon

              Have a read (and play about) with the code that Josh Smith put together here[^].

              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

              As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

              My blog | My articles | MoXAML PowerToys | Onyx

              S Offline
              S Offline
              silverlightnewbee
              wrote on last edited by
              #6

              Dear Josh, I went thru your article and many more articles for bindinf a tree view with database. My problem is still unresolved. my requirement is, I have three tables linked togather as below 1-Order table contains, partyCode and orderNo. 2-Item table contains, orderNo & ItemCode. 3-Stages table contains, orderNo, itemCode & stageCode.(Same stageCode can appear in the table for different items, but not for same Items. Items may or may not have stages. If Item has stages, then entry for such Item will be available in stage table. Otherwise not.) I am unable to generate a tree in below manner: Tree display ord1 ...Item1 .......stage1 .......stage2 ...item2 .......stage1 .......stage2 .......stage3 ...item3 ...item4 ...item5 ...item6 ...item7 ...item8 ...item9 ord2 …… ord3 ……. please help me in generating a tree of such type. I am using dataservices to getch the data from database.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups