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