How to get the corresponding RadTreeViewItem of a BusinessObject?

4 posts, 1 answers
  1. Julien
    Julien avatar
    236 posts
    Member since:
    Jul 2010

    Posted 26 Aug 2010 Link to this post

    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
  2. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 26 Aug 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Julien
    Julien avatar
    236 posts
    Member since:
    Jul 2010

    Posted 26 Aug 2010 Link to this post

    Is there something corresponding for GridList?
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 26 Aug 2010 Link to this post

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