Problem editing RadTreeViewItem, PreviewEditStarted not fired

4 posts, 1 answers
  1. Fernando
    Fernando avatar
    17 posts
    Member since:
    Nov 2010

    Posted 18 Jan 2011 Link to this post

    Hello i have a problem, trying to edit a oRadTreeViewItem

    All tree is generated by code (not binding)

    RadTreeViewItem oRadTreeViewItem = new RadTreeViewItem(); 
    oRadTreeViewItem.Header = "Name"; 
    oRadTreeViewItem.IsEditable = true; 
    oRadTreeViewItem.PreviewEditStarted += radTreeView_PreviewEditStarted; 
    oRadTreeViewItem.Edited += DataViewExplorerTree_Edited;  
    oRadTreeViewItem.EditStarted += radTreeView_EditStarted; 
    DataViewExplorerTree.Items.Add(oRadTreeViewItem);

    I use a context menu to edit the name of tree node using GetItemByPath to find the node

     

     


     


    RadTreeViewItem oRadTreeViewItem = DataViewExplorerTree.GetItemByPath("Path of the item");


    The item put's in edit mode but loss the header content. it's turn in Edit mode with empty content.

    I try to catch radTreeView_EditStarted and radTreeView_PreviewEditStarted in order to rewrite the original header text. But only DataViewExplorerTree_Edited is fired when edit ends. Also trying to set focus to the edit box, but without success (tree is inside a dockpane)

    private void DataViewExplorerTree_Edited(object sender, Telerik.Windows.Controls.RadTreeViewItemEditedEventArgs e)
            {
                RadTreeViewItem targetItem = e.Source as RadTreeViewItem;
                 
               // (e.Source as RadTreeViewItem).IsInEditMode = false;
               //(e.Source as RadTreeViewItem).Background = new SolidColorBrush(Colors.Red);
            }
      
            private void radTreeView_PreviewEditStarted(object sender, Telerik.Windows.Controls.RadTreeViewItemEditedEventArgs e)
            {
                RadTreeViewItem targetItem = e.Source as RadTreeViewItem;
            }
      
            private void radTreeView_EditStarted(object sender, Telerik.Windows.Controls.RadTreeViewItemEditedEventArgs e)
            {
                RadTreeViewItem targetItem = e.Source as RadTreeViewItem;
            }

    I try to use

    oRadTreeViewItem.IsInEditMode = true;
      
    or
           
     oRadTreeViewItem.BeginEdit();  (ALWAYS return false)

    to start to edit node only first runs, the second always return me false.

    Any ideas?

    Thanks in advance.

  2. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 20 Jan 2011 Link to this post

    Hi Fernando,

    There is known issue with setting the IsInEditMode property of the RadTreeViewItem - in certain scenarios, the Header text is lost like in your case. However, you should be able to start editing an item using the BeginEdit() method.

     I prepared a sample project using the code snippets you provided. Can you please have a look at it and let me know if it works for you or if I am missing something? Thank you in advance.

    Greetings,
    Tina Stancheva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Fernando
    Fernando avatar
    17 posts
    Member since:
    Nov 2010

    Posted 21 Jan 2011 Link to this post

    Thanks Tina, i use your sample and runs ok.  I added a Docking pane scenario to this sample (in order to simulate my project)  and runs ok.

    But in my project, when i use BeginEdit() for this RadTreeViewItem i get this exception:

    Telerik.Windows.Controls.Docking.AutoHideArea.EnsurePopupCloseCorrectly.AnonymousMethod__7(object, System.EventArgs)

    Locating source for 'c:\Builds\WPF_Scrum\Release_WPF_2010_Q3\Sources\Development\Controls\Docking\Docking\AutoHideArea.cs'. Checksum: MD5 {71 79 77 4c 32 6c 9e 92 84 7a e7 7a a af a5 4c}
    The file 'c:\Builds\WPF_Scrum\Release_WPF_2010_Q3\Sources\Development\Controls\Docking\Docking\AutoHideArea.cs' does not exist.
    Looking in script documents for 'c:\Builds\WPF_Scrum\Release_WPF_2010_Q3\Sources\Development\Controls\Docking\Docking\AutoHideArea.cs'...
    Looking in the projects for 'c:\Builds\WPF_Scrum\Release_WPF_2010_Q3\Sources\Development\Controls\Docking\Docking\AutoHideArea.cs'.
    The file was not found in a project.
    Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\'...
    Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
    Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
    Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
    The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: c:\Builds\WPF_Scrum\Release_WPF_2010_Q3\Sources\Development\Controls\Docking\Docking\AutoHideArea.cs.
    The debugger could not locate the source file 'c:\Builds\WPF_Scrum\Release_WPF_2010_Q3\Sources\Development\Controls\Docking\Docking\AutoHideArea.cs'.


    Any ideas?

    Thanks in advance.
  5. Fernando
    Fernando avatar
    17 posts
    Member since:
    Nov 2010

    Posted 25 Jan 2011 Link to this post

    Thanks Tina, with your example i found the solution.
Back to Top