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

Parent of SelectedItems

3 Answers 59 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Glenn
Top achievements
Rank 1
Glenn asked on 21 Jul 2010, 07:57 PM
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

3 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 22 Jul 2010, 09:08 AM
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
0
Glenn
Top achievements
Rank 1
answered on 22 Jul 2010, 02:54 PM
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
0
Valentin.Stoychev
Telerik team
answered on 23 Jul 2010, 07:23 AM
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
Tags
TreeView
Asked by
Glenn
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Glenn
Top achievements
Rank 1
Share this question
or