【问题标题】:WPF DataGrid begin editing on Double Click not Single ClickWPF DataGrid 开始编辑双击而不是单击
【发布时间】:2016-05-11 23:26:07
【问题描述】:

我有一个带有可编辑文本列的 WPF DataGrid。 我还可以将它们拖放到不同的视图中。

不幸的是,如果该行已经有选择并且我尝试拖动它,它会进入编辑模式... 我宁愿双击进入编辑模式,这样单击行就可以作为开始拖动。

目前,解决方法是在拖动之前永远不要选择行

我看到了几个类似的问题,但没有一个真正解决这个问题。

【问题讨论】:

    标签: c# wpf datagrid


    【解决方案1】:
    // 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);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2023-01-14
      • 2011-03-26
      • 2014-04-24
      • 1970-01-01
      • 1970-01-01
      • 2021-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多