Controls / Textboxes within RadTreeItem

4 posts, 0 answers
  1. Kevin
    Kevin avatar
    83 posts
    Member since:
    Sep 2008

    Posted 05 Jul 2010 Link to this post

    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??



  2. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 08 Jul 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kevin
    Kevin avatar
    83 posts
    Member since:
    Sep 2008

    Posted 13 Jul 2010 Link to this post

    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.
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 16 Jul 2010 Link to this post

    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
Back to Top