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();
        }
        private void DeleteSelectedRows()
        {
            if (xref == null)
            {
                return;
            }

            if (ShmVarDataGrid.SelectedItems.Count > 0 && MessageBox.Show("Do you really want to delete all selected variables?", "ViGET V2.0", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            foreach (var item in ShmVarDataGrid.SelectedItems)
            {
                SharedMemoryVariable shmVar = item as SharedMemoryVariable;
                if (shmVar.ConnectionCounter > 0)
                {
                    MessageBox.Show("At least one of the selected variables can not be deleted, because it is connected.\n\nNone of the selected variables will be deleted.", "Delete Not Possible");
                    return;
                }
            }

            int indexOfLastDeletedRow = -1;

            //remove all selected rows(shared memory variables)
            while (ShmVarDataGrid.SelectedItems.Count > 0)
            {
                indexOfLastDeletedRow = ShmVarDataGrid.SelectedIndex;
                xref.GetSharedMemoryManager().RemoveShmVar((ShmVarDataGrid.SelectedItem as SharedMemoryVariable).Name);
            }

            //first set focus
            ShmVarDataGrid.Focus();

            //set selected either the last row or the row below last deleted row
            ShmVarDataGrid.SelectedIndex = Math.Min(indexOfLastDeletedRow, ListOfShmVariables.Count - 1);

            //make the selected item visible
            if (ShmVarDataGrid.SelectedItem != null)
            {
                //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);
            }
        }