This is a migrated thread and some comments may be shown as answers.

treeview with usercontrol nodes

2 Answers 30 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Naseem
Top achievements
Rank 1
Naseem asked on 17 May 2011, 06:12 AM
Hi,

I'm looking for a solution to have a treeview which its nodes are usercontrol. I have already defined the usercontrol (that should be instead of tree view node) , however I don't know how I can implement it as treeview.

I'd be thankfull you guide me how I can implement that,

thank you,
Naseem 

2 Answers, 1 is accepted

Sort by
0
Naseem
Top achievements
Rank 1
answered on 17 May 2011, 07:04 AM
Hi,

I have realized I can easily add the user control inside the TreeviewItem.

<telerik:RadTreeView Grid.Row="1" x:Name="treeview">
            <telerik:RadTreeViewItem x:Name="tvItem" Header="Deleted Items(6)" DefaultImageSrc="/Beta.Pres;component/Images/delete_32.png" >
               <Beta:ProductFilterHierarchyPopup></Beta:ProductFilterHierarchyPopup>
            </telerik:RadTreeViewItem>
        </telerik:RadTreeView>

However in my case the tree is generating dynamically in code . I mean I need to add a user control as root ,then in code, based on some bussiness, I'll find the children , then I need to add the children to the root.

ProductDetail productDetail=new ProductDetail();
treeview.Items.Add(productDetail);
  
TreeViewItem treeviewItem = (TreeViewItem)treeview.Items[0];
treeviewItem.Items.Add(productDetail);

Based on above code ,here is what I have done : I Added the usercontrol (ProductDetail) in treeview as root . After that I want to get the root and add its children. but the type of treeview.Items[0] is not a treeviewItem , it's type of usercontrol(ProductDetail).

Would you please help me how I can find specific node in treeview , to be able to add its children.

Thank you,
0
Naseem
Top achievements
Rank 1
answered on 19 May 2011, 01:32 AM
The problem solved.I was able to implement the treeview by using recursive function.

I was looking for a link or something to make my post  as 'answered' or delete it (as it's not any more a question) , but I couln't find any thing !

Thank you,
Tags
TreeView
Asked by
Naseem
Top achievements
Rank 1
Answers by
Naseem
Top achievements
Rank 1
Share this question
or