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

Treeview item with child noes swallows ENTER

1 Answer 9 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 03 Apr 2013, 01:32 AM
I have a treeview with a HierarchicalDataTemplate containing a user control that has a textbox. the textbox has AcceptReturn=true.

If the treeview item has a child node then the treeview does not pass the enter to the UC.

I have this handling the keydown event on the treeview.

private void EnterDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Enter)
    {
        e.Handled = false;
    }
}

How do I pass the enter key down to the textbox in the user control in all cases

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 05 Apr 2013, 12:48 PM
Hello Mark,

Unfortunately, it seems that there are differences in the functionality of the TextBox control in Silverlight and WPF. In order to enter a new line in the TextBox (when it is nested in a RadTreeViewItem) in SL, you can press Shift+Enter.

Another way to achieve your goal (which we implemented in the attached project) is to subscribe to the PreviewExpanded and PreviewCollapsed events and check if the focused element is TextBox. If so you can handle the events and the respective RadTreeViewItem will not expand while the TextBox will add a new row into its content. Please note that we also handle the KeyDown event of the TextBox control. By doing this, if you want to expand the RadTreeViewItem using the Enter key you will have to focus the item
itself.

Please take a look at the attached project and let us know if it works for you.

Regards,
Pavel R. Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeView
Asked by
Mark
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or