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. C#
  4. How to binding TreeView to Unlimit Category?

How to binding TreeView to Unlimit Category?

Scheduled Pinned Locked Moved C#
wpfwcftutorialquestion
2 Posts 2 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.
  • Y Offline
    Y Offline
    yuzifu
    wrote on last edited by
    #1

    I have a class like this: <pre> public class EmpCtg { public int ID { get; set; } public string Name { get; set; } public EmpCtg Parent { get; set; } } </pre> Collection of this class: <pre> List<EmpCtg> ListEmpCtg = //....get list<empctg> </empctg></pre> I want binding ListEmpCtg to TreeView, and show look like this: <pre> EmpolyeeCategory | ---------Ctg1 | | ---------Ctg2 | | | | | --------Ctg3 | | | | | --------Ctg4 | | | | | --------Ctg5 . . . </pre> I know that I can write in the code by hand, but I would like to know whether to use DataTemplate? What should I do? Thanks!

    C 1 Reply Last reply
    0
    • Y yuzifu

      I have a class like this: <pre> public class EmpCtg { public int ID { get; set; } public string Name { get; set; } public EmpCtg Parent { get; set; } } </pre> Collection of this class: <pre> List<EmpCtg> ListEmpCtg = //....get list<empctg> </empctg></pre> I want binding ListEmpCtg to TreeView, and show look like this: <pre> EmpolyeeCategory | ---------Ctg1 | | ---------Ctg2 | | | | | --------Ctg3 | | | | | --------Ctg4 | | | | | --------Ctg5 . . . </pre> I know that I can write in the code by hand, but I would like to know whether to use DataTemplate? What should I do? Thanks!

      C Offline
      C Offline
      Christo667
      wrote on last edited by
      #2

      I use TreeView extensively. It is a rather "unique" control with a lot of pitfalls. I strongly suggest you expend the effort and write custom code around your TreeView controls. Otherwise, if you really want to just use binding, refer to this article on CodeProject: Data Binding TreeView in C#[^]

      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