简体   繁体   中英

Display hierarchy in wpf with unlimited number of levels

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!

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

I think it may serve your needs.

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" ) );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM