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.
14 Answers, 1 is accepted
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!
Nikolay Vasilev
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
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
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!
Nikolay Vasilev
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
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
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!
Nikolay Vasilev
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
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.
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
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!
Nikolay Vasilev
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
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
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!
Nikolay Vasilev
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Not sure how you are doing drag and drop but I solved this problem by checking type of originalsource of mouseeventargs. I am performing drag and drop only when OriginalSource is Datagrid. In case of scrollbar Original source is Thumb.
protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed && e.OriginalSource is DataGrid)
{
DragDrop.DoDragDrop(this, dragData, DragDropEffects.Copy);
}
}