Home Forums WPF controls Xceed DataGrid for WPF Drag-Drop in table view

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26546 |

    Hi all,

    Does anyone know how to enable drag-drop feature in the grid with Table view mode. I can drag-drop from two list view but not success with xceed grid and a list view.

    Thanks and Regards.

    Imported from legacy forums. Posted by allforum (had 2286 views)

    Xceed Support
    Member
    Post count: 5658

    There is no built-in DragDrop available in the DataGridControl.

    One way to acheive this is to register to the PreviewMouseLeftButtonDown for DataRow and to handle the drag drop operation using DragDrop.DoDragDrop() passing the DataGridControl’s CurrentItem.

    In your XAML:
    <Style TargetType=”xcdg:DataRow”>
    <EventSetter Event=”PreviewMouseLeftButtonDown”
    Handler=”DataRowPreviewMouseLeftButtonDown”/>
    </Style>

    In your Code Behind:
    void DataRowPreviewMouseLeftButtonDown( object sender, MouseButtonEventArgs e )
    {
    if( e.ButtonState == MouseButtonState.Released )
    return;

    // this will create the drag “rectangle”
    DragDropEffects allowedEffects = DragDropEffects.Move;

    DataRow dataRow = sender as DataRow;

    try
    {
    DragDrop.DoDragDrop( dataRow, dataRow.DataContext, allowedEffects );
    }
    catch( Exception )
    {

    }
    }

    Imported from legacy forums. Posted by Chris [Xceed] (had 3263 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Chris,

    I tried using above code to implement drag & drop within grid but no luck so far. I want functionality to drag and drop rows within grid. It’s about re-ordering items in the list shown by grid.

    would you be able to provide some more info or sample? I am using Datagrid control version 3.7.

     Cheers,

    Hiren Jani 

     

    Imported from legacy forums. Posted by hiren (had 766 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.