WPF DataGrid calls BeginEdit on an IEditableObject two times?

后端 未结 4 875
有刺的猬
有刺的猬 2020-12-09 16:43

I\'ve got a DataGrid bound to a collection of IEditableObject\'s.

Now when I click two times in a cell, it will be opened for editing.

Funny thing is: BeginE

4条回答
  •  無奈伤痛
    2020-12-09 17:38

    +1 @IanGriffiths for diagonsing the Problem. As for a solution (or workaround rather), you can count the number of "pending" Edits. That means something like:

    void BeginEdit()
    {
        _numEdits++;
    }
    
    void CancelEdit()
    {
        if(--_numEdits < 0)
            throw new Exception("WTF?"); 
    }
    
    void EndEdit()
    {
        CancelEdit();
        if(_numEdits == 0)
            commitEdit();
    }
    

提交回复
热议问题