Is there a simple possibility to check if the DataGrid is currently in EditMode (Without to subscribe to BeginningEdit and CellEditEnding)
相关问题
- VNC control for WPF application
- WPF Binding from System.Windows.SystemParameters.P
- XAML: Applying styles to nested controls
- How can I add a horizontal line (“goal line”) for
- How to properly change a resource dictionary
I found a shorter workaround (VB.NET/C#):
VB.NET
C#:
All the answers above using IsEditing on the datagridrow or IsEdititngItem on the IEditableCollectionView are partial answers to me :
If the user enter edition, then clics on any other cell, the EndEdit event is fired but the DataGridRow has still the property IsEditing to True !!! And if you try to find the DataGridCell responsible, its IsEditingProperty Is always false... I think it's a bug. And to have the desired behaviour, I had to write this Ugly workaround
This basicly force the grid to set IsEditing = false on the datagridrow, when any cell stops editing.
It seems you can also get this information from the items view, namely this works:
I have not confirmed this but most likely you could get these flags in a viewmodel if your bound collection provides an IEditableCollectionView.
Ok, I havent found a simple solution and no one pointed me to one. The following code can be used to add an attached property IsInEditMode to a DataGrid. Hope it helps someone:
To use it, set on the datagrid the ProcessIsInEditMode- property to true:
Afer that you will have the IsInEditMode-property in sync with the mode of the DataGrid. If you want also the editing cell, change the code in
BeginningEdit
accoringly.