AddDragInitializeHandler DragInitializeEventArgs cancel issue

2 posts, 0 answers
  1. Ani
    Ani avatar
    1 posts
    Member since:
    Mar 2017

    Posted 22 Mar 2017 Link to this post


    I am having a problem with usage of cancel operation of DragInitializeEventArgs e in DragInitializeHandler.

    After canceling particular items drag functionality it switches to parent item and marks it as chosen for dragging. 

      private void HandleDragInitialize(object sender, DragInitializeEventArgs e)

    if(some condition)



    the item that belongs to mentioned condition will not get dragged but his parent instead.

    Any solution? 

  2. Martin Ivanov
    Martin Ivanov avatar
    2245 posts

    Posted 27 Mar 2017 Link to this post

    Hello Ani,

    This behavior is observed because when you cancel DragInitialize, the event bubbles to the parent item and start the drag operation for it. To prevent the drag from starting you can set the arguments Data and DragVisual. Here is an example in code:
    private void OnDragInit(object sender, DragInitializeEventArgs e)
        if (drag is not allowed)
            e.Data = null;
            e.DragVisual = null;

    I hope this helps.

    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top