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

Problem editing RadTreeViewItem, PreviewEditStarted not fired

3 Answers 146 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Fernando
Top achievements
Rank 1
Fernando asked on 18 Jan 2011, 11:07 AM

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.

3 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 20 Jan 2011, 03:59 PM
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>>
0
Fernando
Top achievements
Rank 1
answered on 21 Jan 2011, 09:41 AM
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.
0
Fernando
Top achievements
Rank 1
answered on 25 Jan 2011, 12:49 PM
Thanks Tina, with your example i found the solution.
Tags
TreeView
Asked by
Fernando
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Fernando
Top achievements
Rank 1
Share this question
or