RadTreeViewItem Events

5 posts, 1 answers
  1. Ziad
    Ziad avatar
    13 posts
    Member since:
    Apr 2009

    Posted 06 Nov 2009 Link to this post

    Hello, from what I understood based on the previous threads here, the DragEnter, DragOver, Drop... events from System.Windows.UIElement are not implemented. I need to catch these events in order to handle the logic for allowing drag/drop of RadTreeViewItems. Does the Drag & Drop manager that you use expose similar events? If so, how can I access them?


    Thank you.

  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 10 Nov 2009 Link to this post

    Hi Ziad,

    Yes, we expose  different DragDrop events than the one on UIElement.

    Please note that the RadDragAndDropManager does not work across different windows or different applications in WPF. If you need this functionality, you will still need to handle the built-in DragDrop events.

    Otherwise you can find an example of drag-drop implementation between different controls in the online examples:

    http://demos.telerik.com/wpf/

    Go to DragDrop -> Tree to Grid

    There you can see how some of the DragDrop events are handled to implement dragging products across different controls.

    All the best,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ziad
    Ziad avatar
    13 posts
    Member since:
    Apr 2009

    Posted 12 Nov 2009 Link to this post

    Hello Miroslav and thank you for your reply.

    In my specific case, I have a three-level tree view hierarchy. The treeview has to abide by certain restrictions when it comes to drag/drop behavior. For example, you can only drag/drop items in the same 'level'. In addition, there is a default tree item which you cannot add items to. In order to accomplish this behavior, I need to capture events such as 'PreviewDrop' and 'PreviewDragEnter'. I tried attaching event handlers to 'DragDrop.PreviewDrop' and 'UIElement.PreviewDrop'. However, neither of these events were being fired when I was dropping items.

    How can I capture these (or at least similar) events in order to control which items are allowed to be dragged and dropped?


    Thank you.
  5. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 18 Nov 2009 Link to this post

    Hi Ziad,

    In your case you have to add a handler to RadDragAndDropManager.DropQueryEvent and handle even the handled events.

    this.AddHandler(RadDragAndDropManager.DropQueryEvent, new EventHandler<DragDropQueryEventArgs>(RadTreeView_DropQuery), true);

    In the event handler you can place your logic for determining whether a drop is possible or not.

    private void RadTreeView_DropQuery(object sender, Telerik.Windows.Controls.DragDrop.DragDropQueryEventArgs e)
    {
        bool dropPossible = this.DetermineWhetherDropIsPossible();
     
        if(dropPossible)
        {
            e.QueryResult = true;
        }
        else
        {
            e.QueryResult = false;
        }
    }

    I have attached a sample project that demonstrates the above functionality with 3 level hierarchy. Have a look at it and let me know if it is of any help.

    Sincerely yours,
    Kiril Stanoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Ziad
    Ziad avatar
    13 posts
    Member since:
    Apr 2009

    Posted 29 Dec 2009 Link to this post

    Thank you Kiril, this is exactly what I was looking for.
Back to Top
UI for WPF is Visual Studio 2017 Ready