Add Level Between Parent and Different Children Properties

2 posts, 0 answers
  1. Kyle
    Kyle avatar
    3 posts
    Member since:
    Mar 2013

    Posted 21 Feb 2014 Link to this post

    I am looking to add a hard coded or static level between a parent class and it's children properties.
    I have a collection of Parent, and the parent class has 2 collection properties named Children 1 and Children 2.

    class Parent {
     public IEnumerable<Child1>Children1 { get; set; }
     public IEnumerable<Child2>Children2 { get; set; }

    I would like a tree to show the following:
    >Children 1
    >Children 2

    I can't seem to figure out the correct combination of HierarchicalDataTemplate or DataTemplate to accomplish this. Can you point me in the right direction?

  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 26 Feb 2014 Link to this post

    Hello Kyle,

    In order to implement this requirement you will need to use a converter when you bind the ItemsSource of the root-level HierarchicalDataTemplate. You will have to manually pass the proper collection of items to the next level and an IValueConverter is a good place to do that in code.

    Unfortunately we don't have an example of this particular scenario but please let me know if you encounter any issues with its implementation and we will gladly assist you further. You can also take a look at this forum thread that describes a similar case.

    Tina Stancheva
Back to Top