Parent of SelectedItems

4 posts, 0 answers
  1. Glenn
    Glenn avatar
    12 posts
    Member since:
    Apr 2010

    Posted 21 Jul 2010 Link to this post

    I am currently spinning through all the SelectedItems. Is there any way to determine what is the parent node for each object in the SelectedNodes collection?

    Thanks,
    Glenn
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 22 Jul 2010 Link to this post

    Hi Glenn,

    Yes - you can use the ParentItem property.

    Regards,
    Valentin.Stoychev
    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
  3. Glenn
    Glenn avatar
    12 posts
    Member since:
    Apr 2010

    Posted 22 Jul 2010 Link to this post

    Thanks Valentin,

    However, I am binding the RadTreeViewItem to a business object and when I do something like this:

    if (this.RadTreeView1.SelectedItems.Count > 0) {
          foreach (telerik.RadTreeViewItem obj2 in this.RadTreeView1.SelectedItems) {
              _Buffer.Add(obj2.DataContext, obj2.ParentItem.DataContext);
          }
      }


    I receive an InvalidCastException - unable to cast my business object to type 'Telerik.Windows.Controls.RadTreeViewItem'

    Thanks,
    Glenn
  4. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 23 Jul 2010 Link to this post

    Hello Glenn,

    This is because the SelectedItems collection contains the list of the busines objects. You need to get the container that has been generated for your object. Please check this help article:
    http://www.telerik.com/help/silverlight/radtreeview-how-to-iterate-through-treeviewitems.html

    All the best,
    Valentin.Stoychev
    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