Using the Silverlight toolkit build a online TreeView

I still remembered that when I worked at the Fetion , We were working very hard to build a coolest buddy list on the world. And we did it! But I can still remember the pain and endless over time working. Build a powerful buddy list is not an easy job at all.

But when I began to look at the TreeView the Silverlight provided , I found it could be a lot easier to build an online buddy list using this control.

I just wrote  some simple lines of code , and I already can see the value to continue working on this control. It basically can fit in all our requirement at that time.

To build a TreeView using this control can be as simple as this:

   1:            TreeViewItem onlineItem = new TreeViewItem();
   2:              onlineItem.Header = "Online(2)";
   3:              TreeViewItem buddy1 = new TreeViewItem();
   4:              buddy1.Header = "Robert";
   5:              TreeViewItem buddy2 = new TreeViewItem();
   6:              buddy2.Header = "Robert Martin";
   7:              onlineItem.Items.Add(buddy1);
   8:              onlineItem.Items.Add(buddy2);
   9:              treeview.Items.Add(onlineItem);
  10:              TreeViewItem offlineItem = new TreeViewItem();
  11:              offlineItem.Header = "Offline(1)";
  12:              TreeViewItem offlineContact = new TreeViewItem();
  13:              offlineContact.Header = "Alex Wong";
  14:              offlineItem.Items.Add(offlineContact);
  15:              treeview.Items.Add(offlineItem);

When you add the the item, you can add any control you want, like the Textbox,Image,Label etc.

The running result is like

TreeViewBuddyListDemo

I can not stop myself to use this control to create a online chat application to compete with Windows Live Messenger :)

BTW:

After I posted my previous blog, I got  an email from the Silverlight toolkit team and talked about the compiling problem the source code used to have. Thanks Jeff.

Published Monday, November 10, 2008 3:37 PM by RobertNet

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)