1

I have a collection of contacts stored as a hierarchy with an unlimited number of levels. To be more specific, each ContactItem has a List<ContactItem>. I have a couple reasons why:

1) Groups of contacts are also ContactItems to allow more flexibility.

2) A family, company, etc may have a phone number, and then each individual has a phone number.

Examples would be "School -> Teachers -> Mr. Perry" or "Smith -> Bob, Elen"

Anyway, I'm wondering if there's an easy way to display such a hierarchy with an unlimited number of levels easily in WPF.

Thanks!

benjer3
  • 657
  • 6
  • 13

3 Answers3

0

You may want to check out this control here: http://www.hardcodet.net/2008/01/wpf-treeview.

I think it may serve your needs.

Chris Dworetzky
  • 940
  • 4
  • 9
0

Can you stop adding new objects and start pointing to them instead

public class Contact
{
   public static List<Contact> Library = new List<Contact>();

   public List<Contact> Contacts = new List<Contact>();
   protected string Name;

   public contact ( string Name )
   {
      this.Name = Name;
      Library.Add ( this );
   }

}

Then

Contact Ahmed = new Contact("Ahmed");
Contact Ghoneim = new Contact("Ghoneim");

Ahmed . Contacts . Add ( Contact . Library . First ( C => C . Name == "Ghoneim" ) );
Ahmed Ghoneim
  • 6,834
  • 9
  • 49
  • 79