private void AddNewRow() { //MessageBox.Show("AddNewRow"); //20130730,SKK if (xref == null) { return; } //add a new shared memory variable at the end of the list xref.GetSharedMemoryManager().AddNewShmVarWithDefaultValue(); //first set focus ShmVarDataGrid.Focus(); //select the last element of the list ShmVarDataGrid.SelectedItem = ListOfShmVariables.Last(); //then create a new cell info, with the item we wish to edit and the column number of the cell we want in edit mode DataGridCellInfo cellInfo = new DataGridCellInfo(ShmVarDataGrid.SelectedItem, ShmVarDataGrid.Columns[0]); //set the cell to be the active one ShmVarDataGrid.CurrentCell = cellInfo; //scroll the item into view ShmVarDataGrid.ScrollIntoView(ShmVarDataGrid.SelectedItem); //begin the edit ShmVarDataGrid.BeginEdit(); }