Hello,
in a XamGrid with hierarchical data, we need to set whole rows or single cells as dragsources, depending on the cell's column (i.e the first cell with description should trigger row dragging, all other cells [carrying the values] should trigger single cell dragging.I've used CellControlAttached for setting up the dragsources, but CellControlAttached is not being called for all cells. It is called for all description cells, but only for the data cells of some rows. The rows where it is called appear to be the first row(s) of each child row collection, but from the 2. or 3. row on (varying) it is not being called for the data cells anymore. Any ideas why this would be? Is there any other way to create the drag sources for every cell in the grid?
Regards
Lars
Hello Lars,
I have managed to achieve the described behavior with the following code:
private void xamGrid_CellControlAttached(object sender, CellControlAttachedEventArgs e)
{
var cell = e.Cell;
DragSource dragSource = new DragSource()
IsDraggable = true,
};
if (cell.Column.Key == "FirstColumn")
cell.Row.Control.SetValue(DragDropManager.DragSourceProperty, dragSource);
}
else
cell.Control.SetValue(DragDropManager.DragSourceProperty, dragSource);
If you need more help, do not hesitate to ask!
Thanks,
Stefana
Hello Stefana,
thank you for you're answer. But I think there is some misunderstanding. xamGrid_CellControlAttached is not fired for every cell in the grid. It is only fired for some cells. How can I set the remaning cells as dragsources if the xamGrid_CellControlAttached event is not fired for these cells?
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
If the above suggestion helped you solve your issue please verify the thread as answered so other users may take better advantage of it.
unfortunately, the abbove suggestion was not helpful, since it did not adress my problem at all (please see my direct reply).
We've integrated the dragsources into the cellstyle-templates in xaml, wich seems to be the only way to achieve seperate drag behaviors for different cell types. With this, it is a bit tricky to get the proper dragsource and droptarget data during dragover and drop, but we finally got it to work.
There is one more issue with the dragging framework: in order to get a smooth enough motion of the drag template across the screen during dragging we had to make sure that OnMouseOver of xamGrid base class is not being called from the override in our derived class. Before we changed that, for some obscure reason the movement of the drag template stopped constantly and made "jumps" and was responding incredibly slow to the actual mouse moving. Is this a known issue? Is there a fix or better workaround for this problem?
Thanks
I have created a sample project for you with the functionality you want. Bascially I copied the default Style of the CellControl and add the DragDrop there. I apllied this Style to all Columns except the first one, because I also handled the CellControlAttached event and add DragDrop to the CellsPanel, which will work only if you drag the first Cell.
Hope this helps you.
Hello Stefan,
thanks for your effort, but as I've mentioned in my last post we have already figured this out ourselves and have implemented the dragdrop in the cellstyle, so this issue is not relevant anymore.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.