Drag drop from grid methods called when dragging scrollbar

14 posts, 0 answers
  1. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 14 Nov 2012 Link to this post

    When I drag the scrollbar in a RadGridView, OnDragInitialize is called. I can't find anything in the DragInitializeEvenArgs that could tell me whether the user is dragging the rows (in which case I am interested) or dragging the scrollbar (in which I want to ignore it). Ditto for the sender (the RadGridView). Its IsScrolling property is set to false whether I am scrolling or not.

    How can I just do dragging when the user has chosen rows, and not other controls such as the scrollbar or vertical frozen column separator.
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 15 Nov 2012 Link to this post

    Hello Valerie,

    I suspect you have set AllowDrag to true on the GridView itself rather then on the rows. That is the reason you are getting drag initialize when scrolling. The best way to deal with this is to set AllowDrag for the GridViewRow like shown in our examples. An alternative is to use the OriginalSource property of the DragInitializeEventArgs to determine what is the exact source of the Drag operation.

    Hope this helps! 

    All the best,
    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 15 Nov 2012 Link to this post

    I solved half this problem. I realize that when restyling I had changed the target from the GridViewRow to the RadGridView. When I change it back to GridViewRow the scrollbar no longer participates in the drag. So this is solved.

    The issue I still have is that the vertical column separator used to separate the frozen (ie, non scrollable) columns from the rest is calling the dragdrop behavior when trying to move it. That is, the mouse changes to a a double-pointed arrow when you hover over this vertical line, indicating that it can be moved. However once you click down and start to drag it, it switches to doing the row drag thing. I would be happy if the user wasn't allowed to drag this column in the middle of the grid (just allow it to be dragged from the column headers) but am not sure if that is a property I can change.
    thanks
  5. Nick
    Admin
    Nick avatar
    593 posts

    Posted 15 Nov 2012 Link to this post

    Hello Valerie,

    Unfortunately I am not able to reproduce the issue on our end. Can you provide some more details on your Rows Drag and Drop implementation?

    Looking forward to hearing from you! 

    Regards,
    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 15 Nov 2012 Link to this post

    Thank you Nikolay. I too discovered that independently (I posted early this morning).
    I still have the problem with the vertical frozen column separator. When I drag it and land in the drag initialize method, the OriginalSource shows me the object from the row, not any indicator that it was this separator. Is there a way to distinguish that the user was dragging this handle and not the row?
    Thanks
  7. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 15 Nov 2012 Link to this post

    oops, sorry, I didn't realize that you had replied to my previous post also. Are you saying that you can't reproduce the problem with the frozen column separator? Are you dragging it from within the grid and not from the header?
  8. Nick
    Admin
    Nick avatar
    593 posts

    Posted 16 Nov 2012 Link to this post

    Hi Valerie,

    I tried it both from the rows and the headers. I am still not able to reproduce it. Unfortunately if the OriginalSource property doesn't tell you if the FrozenColumnsSplitter  is the source of the Drag, it seems there is something wrong either on our side or in your implementation of the DragDrop logic. May I ask you to open a support ticket and send a sample project where the behavior can be observed, so we can tackle the problem directly and provide a solution in the shortest terms? 

    Thank you in advance! 

    Kind regards,
    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  9. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 17 Nov 2012 Link to this post

    Thank you. I submitted ticket 630968 which includes a project.
  10. Nick
    Admin
    Nick avatar
    593 posts

    Posted 19 Nov 2012 Link to this post

    Hi Valerie,

    After looking in the project, the problem is that the column splitter propagates the mouse events to the DragDrop manager. I still haven't been able to reproduce the issue outside of your project, but will continue trying and a fix will be provided in the shortest terms.
    In the meantime, you can use the following workaround:

    private void OnDragInitialize(object sender, DragInitializeEventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("In GridViewDragDropBehavior: OnDragInitialize");
        DropIndicationDetails details = new DropIndicationDetails();
        var item = (sender as RadGridView).SelectedItem;
     
        if (item == null)
        {
            e.Cancel = true;
            return;
        }
     
        details.CurrentDraggedItem = item;
     
        IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);
     
        dragPayload.SetData("DraggedData", item);
        dragPayload.SetData("DropDetails", details);
     
        e.Data = dragPayload;
     
        e.DragVisual = new DragVisual()
        {
            Content = details,
            ContentTemplate = this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
        };
        e.DragVisualOffset = e.RelativeStartPoint;
        e.AllowedEffects = DragDropEffects.All;
    }

    Hope this helps!  All the best,
    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  11. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 19 Nov 2012 Link to this post

    Thanks Nikolay. I added the code you suggested, however, it never hits that code (I set a breakpoint) because it seems OnDragInitialize isn't called unless there is a SelectedItem.

    As for you not being able to reproduce this outside my project (which actually is the Telerik sample drag/drop project) I found that the problem doesn't always happen. That is, if I keep trying over and over, I can get into a state where it works and continues to work for a while. Then all of a sudden it stops working (ie, gets into the drag code) and continues to not work for a while. I am trying to find a reproducible scenario (such as holding the mouse down longer, or adjusting exactly where my mouse is before I click down, or moving my mouse from the left or right) which makes it sometimes work and sometimes not, but I haven't found one. Perhaps you would see the same in your project if you kept at it for a while.

    Thanks, Valerie
  12. Nick
    Admin
    Nick avatar
    593 posts

    Posted 20 Nov 2012 Link to this post

    Hello Valerie, 

    I finally managed to reproduce the issue, however it may prove to be a lot more complex than we would like it to. It seems to be caused by the Fact that the FrozenColumnsSplitter gets the Mouse capture, but since the AllowCapturedDrag property is set the Drag is being executed anyway. 
    For the time being you can set the AllowDrag property instead of the AllowCapturedDrag of the GridViewRow, which should fix the issue. We are going to look into the problem and will provide an official fix as soon as possible. 

    We are sorry for any inconvenience caused! 

    Kind regards,
    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  13. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 21 Nov 2012 Link to this post

    Hi Nikolay,
    I changed the property from AllowCapturedDrag  to AllowDrag. That does fix the frozen column splitter. However now when I drag a row it will only drag (ie get into the OnDragInitialize code) some of the time. What I mean is that sometimes when you drag nothing happens. I try over and over and nothing happens. But then for some unknown reason I try again and now it drags. So it is an intermittent problem. I never saw this problem when I had AllowCapturedDrag set.

    Thanks, Valerie


  14. Nick
    Admin
    Nick avatar
    593 posts

    Posted 22 Nov 2012 Link to this post

    Hi Valerie,

    This can happen when you are trying to start the drag from an element of the row that can capture the mouse (Button, TextBox, etc.). Nevertheless, we have fixed the issue and the fix will be available in our internal build and Service pack next week. 

    We are sorry for any inconvenience caused! 

    All the best,
    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  15. V
    V avatar
    8 posts
    Member since:
    Oct 2012

    Posted 04 Dec 2012 Link to this post

    I too have the same problem, that Horizontal ScrollBar particpates in the dragdrop. When I drag the scrollbar, scrollbar wont move freely. I am styling radgridview cells but not rows. Can you please tell how to solve this issue?
Back to Top
UI for WPF is Visual Studio 2017 Ready