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 With Arbitrary Number of Child Items

TreeView With Arbitrary Number of Child Items

Scheduled Pinned Locked Moved WPF
csharpwpfgraphicsgame-devdata-structures
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.
  • S Offline
    S Offline
    Steve The Plant
    wrote on last edited by
    #1

    Hi there, I'm new to WPF, so bear with me. I'm trying to make something like a class browser. I have a tree of objects, but each child in the tree is based on whether the object has variables of a certain type. For example, say I have an Entity class for my game engine. I can have any number of variables in the class, or any derived classes, but I'm only interested in all the variables of type Vector. So for a hypothetical scene, I'd like to show a tree like: scene entity 1 vector worldposition entity 2 vector worldposition vector lookat vector orientation (I hope that was clear enough) [Edit] An additional challenge is if an entity has a variable of type Entity. So another hypothetical scene might look like: entity 1 vector worldposition entity 2 vector worldposition vector lookat vector orientation entity 3 vector worldposition entity child vector worldposition vector lookat The scene could theoretically keep going like this, covering every child entity. What's the best way to display this in a TreeView? Thanks!

    A 1 Reply Last reply
    0
    • S Steve The Plant

      Hi there, I'm new to WPF, so bear with me. I'm trying to make something like a class browser. I have a tree of objects, but each child in the tree is based on whether the object has variables of a certain type. For example, say I have an Entity class for my game engine. I can have any number of variables in the class, or any derived classes, but I'm only interested in all the variables of type Vector. So for a hypothetical scene, I'd like to show a tree like: scene entity 1 vector worldposition entity 2 vector worldposition vector lookat vector orientation (I hope that was clear enough) [Edit] An additional challenge is if an entity has a variable of type Entity. So another hypothetical scene might look like: entity 1 vector worldposition entity 2 vector worldposition vector lookat vector orientation entity 3 vector worldposition entity child vector worldposition vector lookat The scene could theoretically keep going like this, covering every child entity. What's the best way to display this in a TreeView? Thanks!

      A Offline
      A Offline
      ABitSmart
      wrote on last edited by
      #2

      If you provide a DataTemplate for each of the types, it should pick it up automatically. Check this post[^] from Mark. It should give you an idea.

      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