private void SyncfusionGrid_AddNewRowInitiating(object sender, Syncfusion.UI.Xaml.Grid.AddNewRowInitiatingEventArgs e) { var data = e.NewObject as AusgangsRechnung; data.Datum = DateTime.Now; data.RechnungsNummer = "AR-00-"; }
/// <summary> /// Invoked when the new item is initiated to add into source collection. /// </summary> /// <returns> /// Returns <b>true</b> if the new item has initiated in AddNewRow; otherwise <b>false</b>. /// </returns> /// <remarks> /// AddNew invoked when the cell in AddNewRow goes edit mode . /// </remarks> public virtual bool AddNew() { if (dataGrid.View == null || !dataGrid.View.CanAddNew) { return(false); } if (dataGrid.View.IsAddingNew) { throw new InvalidOperationException("CurrentAddItem should be null when AddNew calls"); } if (dataGrid.AddNewRowPosition != AddNewRowPosition.None) { dataGrid.View.AddNew(); var addNewRowEventArgs = new AddNewRowInitiatingEventArgs(this.dataGrid) { NewObject = dataGrid.View.CurrentAddItem }; var addNewObject = dataGrid.RaiseAddNewRowInitiatingEvent(addNewRowEventArgs); // WPF-19376 - when dynamic itemssource is used, need to set CurrentAddItem based on the addNewObject if (dataGrid.View is CollectionViewAdv) { if ((dataGrid.View as CollectionViewAdv).CurrentAddItem != addNewObject) { (dataGrid.View as CollectionViewAdv).CurrentAddItem = addNewObject; } } var addNewRow = this.dataGrid.RowGenerator.Items.FirstOrDefault(item => item.RowType == RowType.AddNewRow); if (addNewRow != null) { VisualStateManager.GoToState(addNewRow.WholeRowElement, "Edit", true); addNewRow.RowData = addNewObject; } } dataGrid.SelectionController.HandleGridOperations(new GridOperationsHandlerArgs(GridOperation.AddNewRow, new AddNewRowOperationHandlerArgs(AddNewRowOperation.AddNew, null))); return(true); }