treeview with usercontrol nodes

3 posts, 0 answers
  1. Naseem
    Naseem avatar
    70 posts
    Member since:
    Nov 2010

    Posted 17 May 2011 Link to this post

    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. Naseem
    Naseem avatar
    70 posts
    Member since:
    Nov 2010

    Posted 17 May 2011 Link to this post

    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,
  3. DevCraft banner
  4. Naseem
    Naseem avatar
    70 posts
    Member since:
    Nov 2010

    Posted 18 May 2011 Link to this post

    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,
Back to Top