Tuesday, 29 June 2010

Treeview control of Silverlight

Using TreeView is pretty simple to use. It takes TreeViewItem as its child. Depending on child item we can feed TreeViewItem  to TreeView. If we need inner child we will feed TreeViewItem  to TreeViewItem . Like –

<controls:TreeView x:Name="trvLeftMenu"  BorderThickness="0,1,0,0" Margin="0" Width="auto"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> </controls:TreeView>

for (int i = 0; i < builderList.Count; i++)
TreeViewItem item1 = new TreeViewItem();
for (int j = 0; j < builderList[i].SalesOffices.Count; j++)
      TreeViewItem soItem = new TreeViewItem();

Through this way we can build up a tree. Child item and inner child item binding. There are various properties of TreeView and TreeViewItem. Header property hold header name. We can bind image with text in stackpanel then bind that stackpanel as a Header of TreeView.
mhItem.Selected += new RoutedEventHandler(modelHomeItem_Selected);
If we apply Selected event it will execute when we click on items on run time.

No comments:

Post a Comment