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 need to search for HierarchicalDataTemplate here are some samples
http://www.codeproject.com/Articles/36451/Organizing-Heterogeneous-Data-on-a-WPF-TreeView
WPF TreeView HierarchicalDataTemplate - binding to object with multiple child collections
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.