RadTreeView BeginEdit()

2 posts, 0 answers
  1. Simon
    Simon avatar
    3 posts
    Member since:
    Apr 2011

    Posted 20 Jul 2011 Link to this post


    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;
                    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

  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 25 Jul 2011 Link to this post

    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.

    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!

  3. DevCraft R3 2016 release webinar banner
Back to Top