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

How to get the corresponding RadTreeViewItem of a BusinessObject?

3 Answers 71 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Julien
Top achievements
Rank 1
Julien asked on 26 Aug 2010, 08:21 AM
Hi!

I'm adding from the code an object to one of my recursive ObservableCollection. There is a root ObservableCollection that is set as ItemsSource. 

When I add it to my collection, I want to select it on my tree.

So how can do this? I cannot find any methods that permits me to get a RadTreeViewItem of my added object.

I've seen that: http://www.telerik.com/help/wpf/radtreeview-how-to-get-item-by-path.html but I'm not sure there will never two element with the same displayed name

3 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Stanoev
Telerik team
answered on 26 Aug 2010, 09:25 AM
Hi Julien,

You can subscribe for the ItemPrepared event of RadTreeView and select the newly added item there:

void treeView1_ItemPrepared(object sender, Telerik.Windows.Controls.RadTreeViewItemPreparedEventArgs e)
{
    // e.PreparedItem is the RadTreeViewItem container of the newly added item     
    e.PreparedItem.IsSelected = true;
}

I've added a sample project demonstrating this scenario. Let me know if this works for you.

Regards,
Kiril Stanoev
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
Julien
Top achievements
Rank 1
answered on 26 Aug 2010, 12:29 PM
Is there something corresponding for GridList?
0
Milan
Telerik team
answered on 26 Aug 2010, 03:00 PM
Hello Julien,

You can simply add the newly added item to the SelectedItems collection of the grid.


Greetings,
Milan
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
Julien
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Julien
Top achievements
Rank 1
Milan
Telerik team
Share this question
or