I have some problems with DataGrid. When the DataGrid is set to CanUserAddRows a new black row is placed at the bottom of the DataGrid but these row have an unexpected behavior because if I just clik the new row and pass the focus to another cell the row is created even when it is empty. I would like to change the behavior by veryfing if the row is empty avoid the creation of new item but if in the event RowEditEnding I set e.Cancel=true, then the NewItemPlaceHolder desapears and I can not add any row since then. Any body has found the answer for these problem?
protected override void OnRowEditEnding(DataGridRowEditEndingEventArgs e)
{
if ((e.Row.Item as DataRowView).Row.ItemArray[0] == null || (e.Row.Item as DataRowView).Row.ItemArray[0].ToString() == String.Empty)
{
e.Cancel = true;
IEditableCollectionView collection = Items as IEditableCollectionView;
if (collection.IsAddingNew)
{
collection.CancelNew();
}
}
base.OnRowEditEnding(e);
}