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

Controls / Textboxes within RadTreeItem

3 Answers 38 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 2
Kevin asked on 05 Jul 2010, 03:59 PM
Ok, i have a RadTreeView with an Item Source of List<ActivityControl> which is a user control that has a text box, a canvas and a text box in it... my problem is that because the text box is within the RadTreeView whenever i try and click and drag to select text it tries to drag and drop the Selected item!?! this is going to be a pain for users to try and edit text if they cant drag to highlight....

i've uploaded a video to give you an idea!

http://www.screencast.com/users/kevinrhynas/folders/Jing/media/8fb40a9e-c5ce-4c6f-83ba-20054a6d466f

Also on a side note... i pressume that it is the header of each RadTreeItem that sets the "preview" in the draggable bit... how can i set this if i've simply set the "itemsource" to be a list.. as opposed to manually adding these items??



3 Answers, 1 is accepted

Sort by
0
Miro Miroslavov
Telerik team
answered on 08 Jul 2010, 03:54 PM
Hello kevin,

If you don't need the Drag&Drop functionality you can disable it setting IsDragDropEnabled="False".

Otherwise, you'd best use the build in edit mode - this will remove the problem with the text selection and dragging. You can read more about this here.
If you need further assistance please ask us.

All the best,
Miro Miroslavov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kevin
Top achievements
Rank 2
answered on 13 Jul 2010, 10:01 AM
I do need drag and drop, this is the main reason for us using this control, as it an especially good drag and drop list!.... so thats not an option...

aswell as that the edit mode wont really work as each item is an "ActivityControl" object as opposed to just a Textblock... which has multiple controls within it, unless of course you think this solution would work?

Thanks in advance..

kind regards
Kevin.
0
Tina Stancheva
Telerik team
answered on 16 Jul 2010, 09:25 AM
Hi kevin,

Thank you for the clarification. In this case you can handle the PreviewDragStarted() event of the RadTreeView when the appropriate TextBox/s is/are selected. For example, you can use the following sample code:
private void myTreeView_PreviewDragStarted(object sender, Telerik.Windows.Controls.RadTreeViewDragEventArgs e)
{
    UserControl1 draggedControl = e.DraggedItems[0] as UserControl1;
    TextBox textBoxChild = draggedControl.FindChildByType<TextBox>();
    if (textBoxChild.IsFocused)
    {
        e.Handled = true;
    }
}

However, if the UserControl1 contains more than 1 TextBox, you can use the ChildrenOfType() method instead of FindChildByType() and check every TextBox whether it is focused.

I also prepared a sample project illustrating this approach. Please give it a try and let me know if it works for you.

Regards,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Kevin
Top achievements
Rank 2
Answers by
Miro Miroslavov
Telerik team
Kevin
Top achievements
Rank 2
Tina Stancheva
Telerik team
Share this question
or