1
votes

I have a WPF DataGrid with Text columns that are editable. I also am able to drag-drop them and place them in a different view.

Unfortunately, if the row already has selection and I try to drag it, it enters edition mode instead... I rather enter edition mode on double click, so that a single click on the row can be used as a start drag.

Currently, the work around is to never select the row before dragging it

I saw a couple of similar questions, but none actually addressing this problem.

1

1 Answers

-1
votes
// Theres a million ways I'd rather do that
public class DoubleClickEditDataGrid : DataGrid
{
    protected override void OnCanExecuteBeginEdit(CanExecuteRoutedEventArgs e)
    {
        if (e.Parameter is MouseButtonEventArgs)
        {
            if ((e.Parameter as MouseButtonEventArgs).ClickCount <= 1)
            {
                e.CanExecute = false;
                return;
            }
        }
        base.OnCanExecuteBeginEdit(e);
    }
}