Code to check if a cell of a DataGrid is currently edited

后端 未结 4 563
孤街浪徒
孤街浪徒 2020-12-16 01:49

Is there a simple possibility to check if the DataGrid is currently in EditMode (Without to subscribe to BeginningEdit and CellEditEnding)

4条回答
  •  [愿得一人]
    2020-12-16 02:37

    It seems you can also get this information from the items view, namely this works:

    IEditableCollectionView itemsView = stateGrid.Items;
    if (itemsView.IsAddingNew || itemsView.IsEditingItem)
    {
        stateGrid.CommitEdit(DataGridEditingUnit.Row, true);
    }
    

    I have not confirmed this but most likely you could get these flags in a viewmodel if your bound collection provides an IEditableCollectionView.

提交回复
热议问题