Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1590
Drag 'n drop in a datagrid in combination with flexible headers
posted

Hi,

I'm trying to create a xamDataGrid in which the rows can be dragged to another grid. At the same time, the users must be able to rearrange columns, also by dragging and dropping. I can't seem to get both working at the same time. The following snippet is part of my solution:

<Style TargetType="{x:Type igDP:DataRecordPresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:DataRecordPresenter}">
<igWindows:CardPanel x:Name="baseGrid" MouseDown="CardPanel_MouseDown">

<ig:DragDropManager.DragSource>
<ig:DragSource IsDraggable="True" DragChannels="Channel1" Drop="DragSource_Drop" DragCancel="DragSource_DragCancel" DragStart="DragSource_DragStart" DragEnter="DragSource_DragEnter" DragLeave="DragSource_DragLeave">

<!-- ... -->

</ig:DragSource>

</ig:DragDropManager.DragSource>

The problem is that the drag and drop operations for dragging the rows to the other grid kind of "steal" the drag operations from the header sorting. I tried following approaches to solve it without success:

  • Bind the IsDraggable property of the DragSource to the IsHeaderRecord property of the DataRecordPresenter (inverting the boolean).
  • Set the DragSource through a Style, which has a data trigger on the IsHeaderRecord property. Tried both inline and as a static resource.
  • In DragSource_DragStart, I tried to set [e.Cancel=true;] when DataRecord.IsHeaderRecord is true.
  • Add a single column to the left of the grid, and move the DragSource only to that column. Didn't work either.

I'm out of ideas... Can you help me?

Regards, Stefan