public void AddNewMainRow(bool checkLastRow) { if (AllowAdd != true) { return; } var currentRowIndex = (MainRowList.IndexOf(SelectedMainRow)); if (checkLastRow) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true); if (!isvalid) { return; } } var newrow = new TblEmpLeavingTransactionViewModel { Store = Store }; MainRowList.Insert(currentRowIndex + 1, newrow); SelectedMainRow = newrow; }