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
555
Simple Drag and Drop beahvior on WPF XamGrid
posted

How can I implement simple Drag and Drop behaviour in xamGrid ?

I saw some examples with XamDataGrid and other Controls but I need it with xamGrid.

It should be a simple Drag and Drop behaviour where I can Drag a Row in xamGrid and Drop it in the same xamGrid.

The Cells in a row should also be editable but only on DoubleClick. With SingleClick on cell I want to select the Row

like CellClickAction="SelectRow" in SelectionSettings.

Can you give some sample project or link how can I do it with DragDropManager  ?

Parents
  • 34810
    Offline posted

    Hello Karl,

    Thank you for your post!

    To start, the double click editing functionality for the XamGrid is rather simple. You will need to utilize the XamGrid.EditingSettings and set AllowEditing to “Cell” and IsMouseActionEditingEnabled to “DoubleClick.” This will allow you to edit only on double click. The drag and drop functionality for the XamGrid is a bit more complicated.

    I have attached a sample to this reply that is closely related to the one that my colleague Plamen posted here: http://ko.infragistics.com/community/forums/p/46915/253895.aspx#253895.

    In the sample, a custom grid is built that extends the XamGrid. The DragDropManager is utilized to allow dragging. To allow the drop functionality within the same grid, I have included the default style for CellControl in the resources of the custom XamGrid. The DropTarget is placed on the Grid in the ControlTemplate for the CellControl, and the custom RowDrop event is handled on the custom grid. For convenience, a common directory to find this default style is: C:\Program Files (x86)\Infragistics\2014.2\WPF\DefaultStyles\XamGrid\generic.shared.xaml.

    In the event handler for the RowDrop event, I get the CellControl from the Grid that is the DropTarget and retrieve the rowIndex of the row that it belongs to. This will relate directly to the indexes in the data source that is bound to the grid. Because of this, when the drag source is dropped, I retrieve the drag source’s data object and remove it from the bound data source, and re-insert it into the data source at the index of the drop target’s row.

    The sample application demonstrating this is attached.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Developer Support Engineer I
    Infragistics Inc.
    www.infragistics.com/support

    XamGridDragDropCase.zip
Reply Children
No Data