Hi, I'm trying to create a draggable column, but when I set the CellCLickAction to SelectRecord, the dragging doesn't work anymore. I have added an isolated sample that illustrates this behavior. If you start the sample you will see that 1 grid has a draggable column, and the other does not. The only difference is the CellClickAction setting. Any Advice?
Hello,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I handled the PreviewMouseLeftButtonDown event of the first grid and if the OriginalSource is Rectangle I put the CellIntoEditMode – this way you are able to drag it. Please let me know if this helps you or you have further questions on this matter.
Looking forward for your reply.
Hi Stefan, thank you for your response. I just learned from one of the Infragistics articles that UnboundField is now obsolete and should no longer be used. So I tried to replace the UnboundField with a TemplateField like so:
<igDP:TemplateField BindingType="UseAlternateBinding" AlternateBinding="{Binding}">
<igDP:TemplateField.DisplayTemplate>
<DataTemplate>
<Rectangle Width="20" Height="20" Fill="Blue">
<ig:DragDropManager.DragSource>
<ig:DragSource IsDraggable="True" />
</ig:DragDropManager.DragSource>
</Rectangle>
</DataTemplate>
</igDP:TemplateField.DisplayTemplate>
</igDP:TemplateField>
But now the dragging no longer works immediately. I mean that you first have to click the record, and only then can you drag the row using the rectangle. How can I make it so that it works just like the UnboundField did? P.S. If possible, I would rather not change the CellValuePresenterStyle, because I have learned in another post that this can mess up theming. (Once you set a custom CellValuePresenterStyle, it is no longer possible to change the IG Theme). Regards, Stefan
One more thing; it doesn't have to be a column. It would also be nice to have a draggable RecordSelector. Is it possible to restyle the record selector so that it displays a certain icon that can be dragged? Actually this solution would be probably even nicer than a draggable column.
I can suggest you see this forum thread:
http://es.infragistics.com/community/forums/t/78328.aspx
where a similar question is already discussed.
Hope this helps you.
This post ultimately results in having a new product idea created, so basically dragging the RecordSelector is not possible. Also, the other solution proposed by Gergana suggests initiating WPF drag 'n drop programmatically. But we're using Infragistics drag 'n drop, not WPF drag 'n drop, and according to the following post starting drag 'n drop programmatically is not possible for IG drag 'n drop:
http://es.infragistics.com/community/forums/t/71587.aspx
So I don't think that post is going to help me.
So, how about that TemplateField? Can we get that to work? (preferrably without having to restyle CellValuePresenter, because that could mess up theming, as was explained to me in this article: http://es.infragistics.com/community/forums/p/96831/478249.aspx#478249 )
Regards, Stefan
By the way, why is it that the cell needs to be in edit mode before starting drag 'n drop? After all, dragging and dropping is not really 'editing' the record... This dragging used to work before the latest 2014.2 patch without having to start edit mode...
Hello Stefan
When you use the TemplateField, two templates are used DisplayTemplate and EditTemplate and this is the reason you should click twice before you are able to do Drag&Drop. My suggestions is to use UnboundField or even TemplateField, but set its CellValuePresenterStyle. Here you can read how you can use both Styles and Themes:
http://es.infragistics.com/community/blogs/andrew_smith/archive/2009/12/09/common-style-issues-when-using-the-theme-property.aspx
I managed to get things working again. My last statement about the patch was incorrect, the patch itself wasn't the cause of my problems. In the version before the patch, I used to override the DataRecordPresenter template in order to insert some logic for dragging and dropping. This logic was being ignored after redesigning the application to use the ThemeManager. So I made sure this logic was inserted again and this fixed my problem.
However, even though I managed to fix it, I still think this drag 'n drop issue is something that should receive some attention from your development team. It seems the XamDataGrid doesn't support drag 'n drop in combination with a CellClickAction of SelectRecord. Well, at least not without having to "hack" the grid somewhat. I can imagine this is somewhat difficult because both the selection of a record and a drag 'n drop action are initiated by the same user gesture (a mouse down), but that doesn't mean that you have to start hacking to get it right. Well, at least that's my opinion.