protected override void OnAdd() { var model = this.ContextItem as TableModel; if (model != null) { var itemToAdd = new RowModel() { ColumnName = "NewRow", DataType = DataType.String }; var addCommand = new UndoableDelegateCommand("Add new row", new Action<object>((o) => this.AddNewRow(model, itemToAdd)), new Action<object>((o) => this.RemoveRow(model, itemToAdd))); this.Diagram.UndoRedoService.ExecuteCommand(addCommand); } }
private void RemoveRowModel(RowModel rowModel, CompositeCommand command) { var container = this.diagram.ContainerGenerator.ContainerFromItem(rowModel) as IShape; if (container == null) return; foreach (var connection in this.diagram.GetConnectionsForShape(container).ToList()) { var link = this.diagram.ContainerGenerator.ItemFromContainer(connection) as LinkViewModelBase<NodeViewModelBase>; command.AddCommand(new UndoableDelegateCommand( "Remove link", new Action<object>((o) => this.dc.RemoveLink(link)), new Action<object>((o) => this.dc.AddLink(link)))); } }