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

RadTreeView BeginEdit()

1 Answer 83 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 20 Jul 2011, 01:18 PM

Hi

I’m using a RadTreeView to display a simple organization hierarchy. I have set IsEditable to true so the user is able to press F2 to edit the name of the organization. This works perfectly

My client has specifically asked for a button on each item in the treeView, which should do the same as pressing F2.

Button Click is handled in code-behind like this:

RadTreeViewItem item = GetContainer((OrganisationViewModel)((FrameworkElement)sender).DataContext);
            
            if (item != null)
            {
                item.IsSelected = true;
                treeView.UpdateLayout();
                Dispatcher.BeginInvoke(() =>
                    treeView.SelectedContainer.IsInEditMode = true);
            }

First line will find the item-container, and this seems to work also. The last 7 lines are supposed to mimic selecting the item and pressing F2. 

In my test example I have the following tree:

Org 1
Org 2
Org 3
         - Sub org 1
         - Sub org 2

My code works fine for Org 1 and Org 2, but for Org 3, Sub org 1 and Sub org 2, it does not work. The items will not even be selected?

Note: When i debug the code, the first code line will find the correct RadTreeViewItem, and item.IsSelected = true also updates the  treeView.SelectedContainer. I have tried with or without the Dispatcher and BeginEdit() on the item. Nothing works? 

Best regards, Simon

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 25 Jul 2011, 11:42 AM
Hello Simon,

I cannot tell for sure why this happens at your side, I also need more of your code in order to advice you better. However, I tried this and everything works as expected. Please check out my test project and see if it can help you. Thank you in advance.

Regards,
Petar Mladenov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
TreeView
Asked by
Simon
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or