Load RadTreeViewItem

2 posts, 0 answers
  1. jean michel
    jean michel avatar
    36 posts
    Member since:
    Aug 2012

    Posted 21 May 2010 Link to this post


    I need to cover nodes of my treeview. Nodes is objects of the DtoHierarquiaAgrupamento class.
    It follows the code below:
     foreach (Telerik.Windows.Controls.RadTreeViewItem item in RadHierarquia.Items)  

    Unable to cast object of type 'CCM7.DTO.DtoHierarquiaAgrupamento' to type 'Telerik.Windows.Controls.RadTreeViewItem'.

  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 21 May 2010 Link to this post

    Hi jean michel,

    RadHierarquia.Items collection contains items of type DtoHierarquiaAgrupamento. Therefore you need to modify the foreach like so:
    foreach (DtoHierarquiaAgrupamento item in RadHierarquia.Items) 
    or you can do it like so:
    foreach (var item in RadHierarquia.Items) 

    However, if you need to use the RadTreeViewItem containing the item, you can use the ContainerFromItemRecursive method of the RadTreeView:
    RadTreeViewItem treeItem = myRadTreeView.ContainerFromItemRecursive(item);

    Give this a try and let me know if it works for you.

    Tina Stancheva
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top